[fpc-pascal] for .. in loop implementation [off topic - goto ?]

Martin Friebe lazarus at mfriebe.de
Thu Jan 8 12:30:42 CET 2009


Vinzent Höfler wrote:
> Jürgen Hestermann wrote:
>
>>> Mantra: First make it work, then make it fast.
>> In general that's true from the programmer's viewpoint. But this does 
>> not apply to adding language details because there is no 'first make 
>> it work'. Why obscure important implementation details if the only 
>> benefit is saving some writing?
>
> I won't judge on the "only save some writing" here, but generally it 
> *does* apply to language features: If a particular language feature 
> helps you writing correct code faster (by supporting you to make it 
> work instead of relying on your abilities to use the debugger), then 
> it does apply.
>
> The real question is if the (or any other) proposal is "good enough" 
> to do just that, or if it's really some syntactic sweetener (not even 
> sugar, sugar at least contains energy). That's something to discuss.
>
> Let me take a rather extreme point of view: After all, all those for-, 
> while-, and repeat-until-loops are only there to save you from some 
> typing work[0], because Pascal already has a perfectly good 
> loop-construct with which you can do all that: goto. Would you agree 
> here? Probably not.
1) "goto" alone (labels assumed) can not replace any of the loop 
constructs. It must be paired with "if" (or anything to check conditions)

2) Otherwise you are of course right. Following this logic however most 
programming languages (including pascal and assembler) become redundant. 
They have far to many instructions to archive the same thing.
Look at languages like "whitespace" or "brainfuck" and you will see that 
a language which is kept simple (by the meaning of "no unneeded 
instructions" does not need more than 6 to 8 instructions.

SCNR.



More information about the fpc-pascal mailing list