Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2010-08

Proposal: In-out-parameters

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Unknown author

Hello Michael!

You wrote 2010-08-09 [Proposal: Enhanced replacement for assignment operators]:

BTW.: are there "inout" Parameters that are set on entry and written on exit of a procedure, but not modified during the course of the procedure ?

One could propose a new kinds of parameter transmission: copy-in-copy-out and copy-out. In Ada this is a valid method to transmit scalar parameters (as a alternative to reference ("var") parameters). See http://archive.adaic.com/standards/83lrm/html/lrm-06-02.html These kinds of parameter transmission can be used for properties.

Jasper
___________________________________________________________ Neu: WEB.DE De-Mail - Einfach wie E-Mail, sicher wie ein Brief! Jetzt De-Mail-Adresse reservieren: https://produkte.web.de/go/demail02

Reply by email

Vinzent Höfler
to Unknown author
Show quoted text 11 lines
You wrote 2010-08-09 [Proposal: Enhanced replacement for assignment operators]: > BTW.: are there "inout" Parameters that are set on entry and written on > exit of a procedure, but not modified during the course of the procedure ? One could propose a new kinds of parameter transmission: copy-in-copy-out and copy-out. In Ada this is a valid method to transmit scalar parameters (as a alternative to reference ("var") parameters). See http://archive.adaic.com/standards/83lrm/html/lrm-06-02.html

You should at least have used the 1995 version. Ada83 is pretty outdated, even here[tm], considering that Ada2005 compilers are available for about five years now. :D

<http://www.adahome.com/rm95/rm9x-06-02.html>

These kinds of parameter transmission can be used for properties.

Well, it would involve a function call to the getter upon entry and another one to the setter upon exit. So it would be much more than just a by-copy transfer (which usually is nothing more than just using a register holding the value instead of a pointer to the actual memory location).

Vinzent.

Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief! Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail

Reply by email

Unknown author

Hello Vinzent!

You wrote 2010-08-09:

You should at least have used the 1995 version. Ada83 is pretty outdated, even here[tm], considering that Ada2005 compilers are available for about five years now. :D <[http://www.adahome.com/rm95/rm9x-06-02.html]>

You're right. I was lazy. This was the first report I've found. Has something changed for the specs of copy-[in]-out-parameters?

Show quoted text 7 lines
> These kinds of parameter transmission can be used for properties. Well, it would involve a function call to the getter upon entry and another one to the setter upon exit. So it would be much more than just a by-copy transfer (which usually is nothing more than just using a register holding the value instead of a pointer to the actual memory location).

...but only if the properties are implemented via functions. Nevertheless it works whereas a simple reference parameter does not directly, and that's the point of the proposal.

Copy-in-out-parameters can be simulated via a temporary variable which is transferred by reference, like the example I've given for op:= for properties, i.e. tmp:=obj.read_prop; function_call(tmp); obj.write_prop:=tmp;. Probably this simulation is too good and kills the proposal. On the other hand real copy-in-out-parameters can sometimes be a tad faster than reference-parameters...

Regards
Jasper
___________________________________________________________ GRATIS für alle WEB.DE Nutzer: Die maxdome Movie-FLAT! Jetzt freischalten unter http://movieflat.web.de

Reply by email

Vinzent Höfler
to Unknown author
Show quoted text 9 lines
You wrote 2010-08-09: > You should at least have used the 1995 version. > Ada83 is pretty outdated, even here[tm], considering that > Ada2005 compilers are available for about five years now. :D > <[http://www.adahome.com/rm95/rm9x-06-02.html]> You're right. I was lazy. This was the first report I've found. Has something changed for the specs of copy-[in]-out-parameters?

Yes, the rules have relaxed a bit, but not substantially. The biggest change was that Ada95 made out-mode parameters readable, in Ada83 they were write-only, which many people considered a bit awkward. But that's a language detail which wouldn't concern us in FPC, out mode parameters are already read-write, and there's no reason to "fix" that.

Show quoted text 9 lines
> Well, it would involve a function call to the getter upon entry > and another one to the setter upon exit. > So it would be much more than just a by-copy transfer > (which usually is nothing more than just using a register holding > the value instead of a pointer to the actual memory location). ...but only if the properties are implemented via functions. Nevertheless it works whereas a simple reference parameter does not directly, and that's the point of the proposal.

Yes. In that way, properties would behave like normal variables again. I'd like that. ;) But there was a reason, why FPC doesn't support that anymore.

Vinzent.

GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT! Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01

Reply by email