This sounds like another job for the macro language.
Anyone have any idea what the macro language should look
like, aside from that the variables in it which will get
replaced might wear hats?
defining -language-macro might be premature because identifying
what suggestions and shortcuts make more sense as macros is a little
tricky; what we need to do is gather up a collection of all
the short rewrites we want to be able to do, ( including in my opinion
perl-5-isms like the postfix if/while/for ) and produce a language in
which they can all be succinctly and clearly declared.
Ones we like get to be standard macros (such as this one)
The difference btn a macro and a subroutine is, the interface is completely
different, and the macro does not create a coderef and register it with
the symbol table, rather it defines a way to rewrite and registers that with
the parser or lexer or "clarify" function (at some level.)
If these are all tagged to key words, that makes inplementation a lot
easier than if they are tied to syntax: After getting a token out of
the code, the lexer examines the tags of the token for macro definitions
and checks each one's rules to see if any match and if so does what is
defined.
Peter's "in" keyword would, in the (tokenize then clarify) language
I wrote over the weekend (and have written on two pads of paper, really I do)
be implementable as something tied to something very similar if
not exactly BOOLEAN_BAREWORD_in and this something would check to see
if the previous token can be coerced into a scalar and the next token
can be coerced into a list and if so, expand.
Macro expansion has the problem of expressions with side effects
appearing multiple times for no identifiable-by-beginners reasons, so
that is an argument against it.
Adding something to the parameter-list-specification language that
will look over to what-is-on-the-left-of-the-keyword is another
possibility.
Should this go to -internals ?
Markus Peter wrote:
>
> I'd like to see a new builtin named "in" which does the same as "in" in SQL.
> Basically,
>
> print "OK!" if $val in ("foo","bar","bla");
>
> is the same as
>
> print "OK!" if grep { $_ eq $val } ("foo","bar","bla");
>
> or
>
> print "OK!" if $val eq "foo" or $val eq ....
>
> except it's a lot more compact, intuitive to use and readable...
>
> --
> Markus Peter - SPiN GmbH
> [EMAIL PROTECTED]
--
David Nicol 816.235.1187 [EMAIL PROTECTED]
Laziness with responsibility http://www.tipjar.com/kcpm