>> -----------------------------------------------------------------------
>> with Uebergabe^, Qarray[QuaderNr]^.Teilung[R] do
>> AusdehnungInMeter := (Feldgrenzen[length(Einteilungen)+1] -
>> Feldgrenzen[1]) *
>>
EinheitAuswahl[Einheit.Koord[R]].Faktor;
>> -----------------------------------------------------------------------
>>
> Why put Uebergabe^ in the with? It appears only once?
Yes, that's true. I just picked an arbitrary example from my code to get
the idea. I have lots of with statements with similar "with-variables".
Sometimes they are used only once and in other cases they are used more
often.
> Assuming objects, better add helper methods
> function TFooTeilung.GetLastFirstDiff;
> begin
> Result := Feldgrenzen[ length(Einteilungen)+1 ] - Feldgrenzen[1];
> end
I don't want to add runtime penalties by calling functions (with stack
handling overhead).
> AusdehnungInMeter :=
> Qarray[QuaderNr]^.Teilung[R]. GetLastFirstDiff
> * EinheitAuswahl[Uebergabe^.Einheit.Koord[R]].Faktor;
> You can also introduce
> FeldgrenzenBackwards[x]
> where 0 returns the last, 1 the one before last ....
Same reason: It's slower and does not add any benefit.
Of course, there is an inifite way of coding things and the with
statement is one of them.
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus