Subject:
|
Re: Perl rules!
|
Newsgroups:
|
lugnet.off-topic.geek
|
Date:
|
Sun, 20 Jun 1999 04:05:38 GMT
|
Viewed:
|
645 times
|
| |
| |
Todd Lehman wrote in message ...
> In lugnet.off-topic.debate, Larry Pieniazek writes:
> > > high-level** languages.
> > >
> > > ** Languages with features like closures, late binding, lambda functions,
> > > in-memory compilation of arbitrary code constructed on-the-fly, regular
> > > expression manipulation, arbitrary namespaces, and of course OO.
> >
> > I agree with most all you say, but I am surprised that you consider
> > this:
> >
> > in-memory compilation of arbitrary code constructed on-the-fly,
> >
> > necessary for a language to be "high level".
>
> I didn't mean to say that it was necessary for a language to be "high level"
> but it certainly is a common property of high-level langauges (for example
> Lisp/Scheme, Logo, PostScript*, and Perl).
>
>
> > I rather consider it a
> > potential pitfall for the unwary instead of a feature. I certainly agree
> > that it's a sign of a good/powerful/rigorous design to be able to do it.
> > But I dispute that it's useful. I've not seen a situation yet where I
> > needed it, and I consider myself pretty good at doing clever things
> > programmatically.
>
> It certainly has a variety of mis-uses, but where it really shines is that
> it's a wonderfully elegant way to implement special-purpose or extension
> languages for doing various things. You slurp in a file of code (written
> in your special language) and transmogrify this into the target language
> (i.e. Perl or Lisp) and then execute that, either on-the-fly or save the
> compiled/translated version back to disk for re-use later without having
> to retranslate.
I've always had a sport in my heart for SNOBOL which had an eval function to
evaluate an expression, and a compile function if you needed real code. I
used the expression evaluation capabilities to add debugging capability to
some programs (for litterally a handfull of lines of code, you could take
the input and determine, "gee this is a debugging command", and fire it
off). It also had one of the most bizzare syntaxes, but an incredibly simple
one (the BNF for SNOBOL is 4 1/2 pages, a syntatic recognizer program is 2
pages, and doesn't look that much different than the BNF (in a not too
extreme simplification of SNOBOL, it in fact essentially has a single type
of statement, all the other statement types are just special cases - SNOBOLs
forte is pattern matching/replacing, and branching can be part of any
statement). Its also one of only a small number of programming languages
which separate the concept of success/failure of an operation from the
results of the operation. Icon, a more standard procedural followon to
SNOBOL improves on this separation of success/failure, in part by improving
the programmer's control of it (Icon has some interesting subtlties also, a
for loop in Icon looks on the surface to be the same type of syntax as in
"normal" languages, except that it is actually an expression because the
actuall loop control utilizes the success/failure mechanism (an Icon for
loop looks like "every 10 to 100 by 10 do". to-by is actually a trinary
operator (in which if the by is not present is assumed to be "by 1)). Icon
also allows expressions to not just return a single value, but a sequence of
values (every is a control structure which forces an expression to generate
its entire sequence of values, the sequence is terminated not by a special
value, but by the expression failure mechanism. One of the bummers in a way
for me is that Icon doesn't have the capability to compile code at runtime.
It is also a little harder to write pattern matching/substitution code in
Icon than in SNOBOL, but you have incredibly more control over it. Another
weird thing Icon has is reversible operations (you can assign a value to a
variable in part of an expression for example, and then if in the end, the
expression fails, you can undo the assignment). Another neat feature Icon
has is functions which can suspend themselves, and then be resumed (one use
of this is to write a function which generates a sequence of values). Both
SNOBOL and Icon are also soft typed languages (in fact, if you're not
carefull in Icon you can really shoot yourself in the foot, one of the data
types is "function". When you code a function, the compiler creates a global
variable with the name of the function, and assigns it an intial value of
the function (another syntactic oddity, the () in Icon are an operator,
which says "Evaluate each expression contained in succession, if any fail,
evaluation stops, and the failure is propagated. Once all the
sub-expressions are evaluated, look at the value to the left, if its a
function value, call the function, passing the results of the
sub-expressions as parameters, if its a number, return the result of the nth
expression" (so 2(f(a), g(b), h(c)) produces as it's result, g(b), but if
and only if all three expressions succeeded, and btw, if f(a) failed, g(b)
and h(c) will never be evaluated).
Ok, time to get off my tell the world about how neat SNOBOL and Icon are
(well one last thing, I also always thought it was neat that the native code
compiling version of SNOBOL was called SPITBOL (for speedy implementation of
SNOBOL))...
Frank
|
|
Message is in Reply To:
| | Re: Perl rules!
|
| (...) I didn't mean to say that it was necessary for a language to be "high level" but it certainly is a common property of high-level langauges (for example Lisp/Scheme, Logo, PostScript*, and Perl). (...) It certainly has a variety of mis-uses, (...) (25 years ago, 19-Jun-99, to lugnet.off-topic.debate, lugnet.off-topic.geek)
|
433 Messages in This Thread: (Inline display suppressed due to large size. Click Dots below to view.)
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|