Larry Wall wrote:
>
> David L. Nicol writes:
> :
> : [this parser switch thing]
> : sounds a lot like an "exec" system call: there are some things
> : which remain in effect (open file handles, current directory,
> : environment) but there are many others which do not. Maybe
> : switching parsers is best an absolute kind of thing rather than
> : a stacked kind of thing, with the later parser responsible for
> : switching back.
>
> The truth is somewhere in the middle. It is incumbent on the
> outer rule to inform the inner rule how it thinks the inner rule
> ought to terminate, and it is the choice of the inner rule whether
> to follow the convention suggested by the outer rule. A rule that
> starts at a left parenthesis will suggest stopping on a right
> parenthesis, but if the inner rule is parsing troff, all bets are
> off on properly nesting parens.
>
> Larry
Right. The existence of these "all bets are off" cases is what
makes, IMO, a non-stacked system look better. If the conversation
starts in Russian, switches to Chechen, then Turkish, then English,
the conversants might want to switch back to Russian without having
to say a single word of Turkish or Chechen on the way back. Or they
might not switch back at all!
What I see as needed is a designated meta-token that will be
reserved, in some form or another, as the switch-parser command.
In human language you just switch, and the conversants notice that
a switch has occured and if they are fluent they, by default, switch
too -- this behaviour is confirmable by anyone who has spent time
slacking at an embassy. The consensus remains that computers are not
yet ready to figure out which of the languages they can understand
they are being addressed in, even though the mechanism (start all the
interpreters and the one that doesn't err out is the winner) has been
available in science fiction since the early seventies (I encountered
it in a yellowing paperback in 1977, the plot involved a midwestern
dystopia run by a central computer which had been set up by a lone
genius who later disappeared: it appeared to the naive that "the
computer was running amok and killing people" but the protagonist
was able to rule out mechanical error, eventually the culprit
is cornered after a variety of suspensful moments -- Does anyone
know the title of the book? I'd like to read it again now that I
have Adult Perspective -- addititional remembered plot and setting
details available on request)
... so we can't have the programs just switch. Even if they leave
five consecutive blank lines between them?
What about a hash-bang? Maybe putting a hash-bang in the middle
of the text (outside of quoted literals, of course) could indicate
that the referenced program is to take over the parsing duties.
The problem with the oughts and incumbencies is, you have to come
up with a whole minilanguage for telling the inner rule, "parse until
you get to a right angle bracket at the beginning of a line" or
something like that -- but then what have you gained over HERE
notation?
HERE notation is grand for language nesting: all those millions
of perl programs that output HTML are a perfect example. But to
replace the whole parser (replacing part of the parser can be reduced
to replacing the whole parser with a very similar one) we don't
care if we come back. We might not come back. We just need to choose
a syntax for the transition.
__PARSER_NAME__ matches other parts of the language
behind the scenes the linkage could be arbitrarily complex, some
languages might not be able to handle transitioning directly into
some others, others might be able to switch over in medias. I don't
know enough python to produce an example of a fragment that
starts in perl and does
__PYTHON__
to do some python-style array slicing using the variable names
which had been momentarily before prefixed with @ symbols then
does
__PERL__
some time down, after the loops opened up with right curlies
before the first switch have been closed by abandonment of
indentation. That would be based on some very sophisticated
handshaking, where the second language could close the first
one's scopes and so on.
What is the minimum granualrity of JPL? Can you write the
first five lines of a function in JAVA and the last five lines
in Perl?
And the default case, the sensible autovivification, on encountering
a __FUTBOL__ token would be to throw a syntax exception: Whatever
is managing the developing op-code tree would have to catch those
and see if it has a FUTBOL parser. Or throw an exception because
it doesn't.
--
David Nicol 816.235.1187 [EMAIL PROTECTED]
"Described as awesome by users"