Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Pascal Misc > Re: freepascal ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 8 of 19 Topic 718 of 811
Post > Topic >>

Re: freepascal strings

by Wolf Behrenhoff <NoSpamPleaseButThisIsValid3@[EMAIL PROTECTED] > Feb 19, 2007 at 10:09 PM

Marco van de Voort schrieb:
> On 2007-02-19, Richard Engebretson <eng@[EMAIL PROTECTED]
> wrote:
>>> I didn't look at fpc - but Turbo Pascal does the following when foo is
>>> called:
>>> - it pushes the number to the stack
>>> - it pushes the address of the string (so, you're right, it is passed
by
>>> reference; also in case a). BUT the foo procedure itself then does a
>>> "sub sp, sizeof(str)" and copies the string. But that is just an
>>> internal detail, I don't know if FPC does it the same way.
> 
> This is normal. This is because "by value" (without const/var/out) means
> that the procedure can modify, but that the modications shouldn't
propagate
> back.

Of course. Wouldn't it be possible to push the whole string on the stack
before doing the call instead of pu****ng the address and letting the
called function copy the string? That was my point!

> Due to the fact that implementations of units can be compiled
separately,
> the caller can't know if e.g. a procedure won't modify it.

I don't understand what you're saying here. The caller needs to know if
it is a var, const or (none) parameter. Think of an integer. If it is
foo(i:integer), the value is pushed. If it is foo(var i:integer), the
address is pushed (of course). So it must be possible to do this for
strings!

So what is the problem? Is it open strings? Or performance issues?

Wolf
 




 19 Posts in Topic:
freepascal strings
"Richard Engebretson  2007-02-17 19:16:39 
Re: freepascal strings
Wolf Behrenhoff <NoSpa  2007-02-18 14:01:05 
Re: freepascal strings
"Richard Engebretson  2007-02-19 03:13:17 
Re: freepascal strings
Wolf Behrenhoff <NoSpa  2007-02-19 15:22:41 
Re: freepascal strings
CBFalconer <cbfalconer  2007-02-19 19:04:06 
Re: freepascal strings
"Richard Engebretson  2007-02-19 09:09:46 
Re: freepascal strings
Marco van de Voort <ma  2007-02-19 20:41:13 
Re: freepascal strings
Wolf Behrenhoff <NoSpa  2007-02-19 22:09:24 
Re: freepascal strings
Marco van de Voort <ma  2007-02-20 08:38:07 
Re: freepascal strings
Wolf Behrenhoff <NoSpa  2007-02-20 13:58:34 
Re: freepascal strings
Jonas Maebe <Jonas.Mae  2007-02-20 14:58:14 
Re: freepascal strings
"Richard Engebretson  2007-02-19 09:37:20 
Re: freepascal strings
Wolf Behrenhoff <NoSpa  2007-02-19 21:19:34 
Re: freepascal strings
Marco van de Voort <ma  2007-02-19 20:43:07 
Re: freepascal strings
Wolf Behrenhoff <NoSpa  2007-02-19 21:56:35 
Re: freepascal strings
Marco van de Voort <ma  2007-02-19 21:19:37 
Re: freepascal strings
Marco van de Voort <ma  2007-02-19 21:27:00 
Re: freepascal strings
CBFalconer <cbfalconer  2007-02-19 19:07:59 
Re: freepascal strings
"Richard Engebretson  2007-02-19 13:15:18 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 0:50:16 CDT 2008.