On 12 September 2010 12:33, Mike Caron <[email protected]> wrote: > On 9/11/2010 8:18 PM, Ralph Versteegen wrote: >> >> On 12 September 2010 09:16, James Paige<[email protected]> wrote: >>> >>> On Sat, Sep 11, 2010 at 05:06:22PM -0400, Mike Caron wrote: >>>> >>>> On 9/11/2010 4:27 PM, James Paige wrote: >>>>> >>>>> I keep forgetting about BYREF. I know when to use it on ints, and I >>>>> know >>>>> never to use it on strings, and I know it is utterly and completely >>>>> irrelvant on arrays >>>>> >>>>> But what I can't remember is whether it matters for UDTs >>>> >>>> You generally want to pass UDTs BYREF, especially if you want to modify >>>> the UDT in the sub. You can pass them BYVAL, but: >>>> >>>> 1. They will be read only (it passes a copy) >>>> 2. If the UDT is big and passed around frequently, it will be >>>> considerably slower than passing BYREF. >>> >>> But doesn't -lang deprecated pass them BYREF by default or something? >>> >>> That would explain why all the many times I have forgotten to specify >>> BYREF on UDTs has not broken anything (that I have noticed yet). >>> >>> --- >>> James >> >> UDTs by default are always passed BYREF, in all dialects, so I'd >> rather we didn't specify BYREF. >> >> What I didn't realise was that Option Byval changes UDTs to pass BYVAL >> by default! Argh! How could the FB devs be so cruel to us! :( > > You know, in most languages, UDTs are passed BYVAL BYDEF- er, by default. > Like, in C for example.
But BYREF is what you want 98% of the time, so it's a better default. C didn't have references. > Besides, wouldn't you want it to be consistent everywhere? I'd have liked to be able to switch to the lang fb behaviour. lang deprecated users; second class citizenry. >> On the whole our code will be cleaner if we explicitly pass all UDTs >> BYREF, declare Option Byval everywhere, and then remove all the >> explicit BYVAL passing of integers. But I'm a bit less motivated to do >> so now. >> _______________________________________________ >> Ohrrpgce mailing list >> [email protected] >> http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org > > _______________________________________________ > Ohrrpgce mailing list > [email protected] > http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org > _______________________________________________ Ohrrpgce mailing list [email protected] http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org
