ActionScript: => was {Re: [Edu-sig] Top 5 All Time Novice Obstacles => #3 Where am I ?}

Tim Peters tim.one@comcast.net
Mon, 23 Sep 2002 10:51:52 -0400


[Guido]
> I've not looked much at it personally, but I trust a close colleague
> who has, and who finds it hard to use because the parser cannot know
> the end of a function's parameter list -- that's only known at run
> time, once the function is called.  Sounds like dead on arrival to me,
> as far as language design goes.

[Jason Cunliffe]
> hmm... I do not understand what your friend means about the parser.
> I don't know much about parsers, but will ask around more.

Well, I'm just a friend of Guido's <wink>, but here's *almost* an actual
line of Rebol from a sample program (make-doc-pro.r) on the website.  It's
"almost" because I had to split the line to fit in my screen width; the
original was all on one line:

destinationfile: join first split-path file append first parse/all second
                 split-path file "." ".html"

Now as a Rebol programmer, you happen to know that "join" takes 2 arguments.
There's no way to guess that from staring at the code above, and now that
everyone else here knows that "join" takes 2 arguments, let's see how well
they can guess what those arguments might be in the above.  Or is there
indeed *more* than just one top-level call to "join" in the above?  You
can't guess that either from staring at the code -- you have to know which
of the words are functions, and how many arguments each function takes(*).

When I played with Rebol, this kind of thing drove me nuts:  because line
boundaries aren't significant either, there are no reliable visual clues
about the scope of function calls, where arguments begin or end, or even
where conceptual statements begin and end.  Make one mistake, and it can
have semantic effects to the very end of the file's source code.  That makes
tracking down a runaway triple-quoted string in Python look like pure joy.

I grant that the quoted line above is extreme in Rebol practice, but the
"make one mistake" business isn't.  Forget an argument, and Rebol will
merrily chew up following lines at runtime until it finds a complete
expression to *use* for the missing argument.  Add an extra argument, and
Rebol doesn't care either -- it will just take the start of the first excess
argument as the start of a new function call.  The lack of redundant syntax
is pleasant in short and correct programs, but doesn't scale.


(*) If you give up <wink>, "join", "append", and "parse/all" take 2
arguments each.  "first", "split-path", and "second" take 1 argument each.
"file" is not a function.  Here's how to read it:

join
    first
        split-path
            file
    append
        first
            parse/all
                second
                     split-path
                         file
                "."
        ".html"

Rebol has some very cool ideas, btw -- this wasn't one of them.