Re: Local variables controversial?
- From: Andrew Haley <andrew29@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 26 Jul 2005 17:08:07 -0000
bobjaffray@xxxxxxxx <bobjaffray@xxxxxxxx> wrote:
>> 4 of 6
>>Date: Sun 24 Jul 2005 18:16
>>From: Andrew Haley
>>bobjaffray@xxxxxxxx <bobjaffray@xxxxxxxx> wrote:
>>> Local variables controversial?
>>>>Date: Fri 22 Jul 2005 16:14
>>>>From: Andrew Haley
>>Forth is designed so that calling a word has a very low overhead.
>>That's the idea: provide a langauge with a tiny subroutine overhead
>>in order to encourage programmers to use subroutines.
> bj: Right. But high-level Forth has considerably more
> overhead than inlined subroutines.
I guess you're assuming that the overhead of inlining a subroutine is
zero. That may be so, but inlining is an implementation technique that
Forth can use too, so it's irrelevant to this particular point.
> Yes, compared to other languages calling a subroutine has
> considerably less overhead.
Right. This is the *essential thing* about learning Forth: don't worry
about calling words. Factor, factor, factor.
>>No, no, that's not it _at all_.
> bj: Well it is sometimes, though perhaps not all that often
> the way Forth is usually written.
>>Forth is supposed to be composed of a bunch of small words, each of
>>which expresses a single idea.
> bj: That is _supposed_ to be it. But in F83 I find "single ideas"
> often broken down into fragments of ideas. (I am still open to
> suggestions about a modern public domain ANS Forth.)
Perhaps: I have no real idea of the codebase you're looking at.
>>That doesn't make it wordy: usually quite the reverse.
> bj: If you are referring to the artificial names often given in
> other languages I agree. However, because of the small size of words
> in Forth compared to other languages there inherently is a larger
> number of names.
Not absolutely, because you don't have lots of local variable names.
Also, and this is harder to quantify, Forth style tends not to produce
a blizzard of names. But yes, you do have a lot of words.
> (Of course, right choice of names for words helps to make Forth more
> readable, and _vice versa_ - poor choice makes can make it almost
> impossible.
>>> It often does not really improve the structure of the code, but is
>>> done to work-around the limitations of traditional code
>>> constructs.
>>I strongly disagree.
> bj: I have in mind the words EXIT and LEAVE in F83, which I take it
> are pretty much standard words. I always find myself wanting to
> EXIT to the end of a looping construct (other than DO ... LOOP)
> rather than exiting a word.
Well, you'd have to explain further, but if you really do want to
leave a loop in the middle you can always use WHILE. But complex
looping structures are an ANS thing that you don't have in F83.
> bj: Maybe you can suggest a practical way for me to approach my mind
> block.
>>It is sometimes possible to factor too far, when a single idea is
>>split into parts, but that is far less common than overlong
>>definitions.
> bj: I don't see overlong definitions in F83 source.
Glad to hear it. It's been a long while since I looked at F83, but
from what I remember it was pretty clean.
Andrew.
.
- References:
- Local variables controversial?
- From: bobjaffray@xxxxxxxx
- Re: Local variables controversial?
- From: Jeff Fox
- Re: Local variables controversial?
- From: Jeff Fox
- Re: Local variables controversial?
- From: bobjaffray@xxxxxxxx
- Re: Local variables controversial?
- From: Andrew Haley
- Re: Local variables controversial?
- From: bobjaffray@xxxxxxxx
- Re: Local variables controversial?
- From: Andrew Haley
- Re: Local variables controversial?
- From: bobjaffray@xxxxxxxx
- Local variables controversial?
- Prev by Date: Re: Local variables controversial?
- Next by Date: Re: Local variables controversial?
- Previous by thread: Re: Local variables controversial?
- Next by thread: Re: Local variables controversial?
- Index(es):
Relevant Pages
|