Sign in Join

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

Mailing lists / fpc-pascal / 2015-06

record helpers & how they effect records

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

David Emerson

using a simple record, e.g.

some_record_type = record
   a, b : longint;
   end;

If I declare a record helper, does this change the record in any way? i.e. does the record take any more space when passed as a function parameter? Does it become somehow like an object, and need to be allocated? Or is the helper more like a language shortcut/convenience, where the compiler still treats the record the same way, and declaring and using the helper is equivalent to declaring and using a function that takes the record as a parameter?

I'm using mode objfpc

Thanks!
~David

luiz americo pereira camara
to David Emerson

I'd like to extend the question to class helpers, i.e., declaring and using the helper is equivalent to declaring and using a function that takes the class instance as a parameter?

Luiz

"David Emerson" wrote 24 lines
using a simple record, e.g. some_record_type = record a, b : longint; end; If I declare a record helper, does this change the record in any way? i.e. does the record take any more space when passed as a function parameter? Does it become somehow like an object, and need to be allocated? Or is the helper more like a language shortcut/convenience, where the compiler still treats the record the same way, and declaring and using the helper is equivalent to declaring and using a function that takes the record as a parameter? I'm using mode objfpc Thanks! ~David _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Michael Van Canneyt
to David Emerson: using a simple record, e.g. some_record_type = record a, b : longint; end; If I declare a…
David Emerson wrote 9 lines
using a simple record, e.g. some_record_type = record a, b : longint; end; If I declare a record helper, does this change the record in any way? i.e. does the record take any more space when passed as a function parameter? Does it become somehow like an object, and need to be allocated?

No. It remains a record.

Or is the helper more like a language shortcut/convenience, where the compiler still treats the record the same way, and declaring and using the helper is equivalent to declaring and using a function that takes the record as a parameter?

Yes, this is correct. It's syntactical sugar. The basic layout of a record is not changed.

Michael.