A Lispish Perl? 
Author Message
 A Lispish Perl?

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl,

:Has anyone tried to write a language (or a set of extensions to Lisp)
:that has the basic functionality of Perl (easy pipes, pattern
:matching, and string processing) with straightforward Lisp-like syntax
:and flexible data structures?  I'm currently using Perl and Common
:Lisp, and I wish I could combine their strengths.  Please send mail (I
:don't have the time anymore to read netnews thoroughly!) if you have
:or know of any system similar to what I'm getting at, or know of Lisp
:tools I could use to build it.

It's been too long for me to recall all that lisp offers -- what kinds of
data structures are you looking for?  Perl has a pretty rich set of
first-class data and code thingies, including strings and numbers (even
bignums), arrays (lists) and associative arrays (alists), objects and
references and closures, plus some o-o tricks for transparently
intercepting variable access to transparently trigger user-defined fetch
and store (etc) methods.  I have a document at http://www.*-*-*.com/
that starts to talk about some of these in more detail that other perl
documentation does.

What other stuff would you be looking for?

--tom
--

    A formal parsing algorithm should not always be used.
                    --D. Gries



Wed, 15 Apr 1998 03:00:00 GMT  
 A Lispish Perl?

Quote:

> [courtesy cc of this posting sent to cited author via email]
>In comp.lang.perl,

>:Has anyone tried to write a language (or a set of extensions to Lisp)
>:that has the basic functionality of Perl (easy pipes, pattern
>:matching, and string processing) with straightforward Lisp-like syntax
>:and flexible data structures?  I'm currently using Perl and Common
>:Lisp, and I wish I could combine their strengths.  Please send mail (I
>:don't have the time anymore to read netnews thoroughly!) if you have
>:or know of any system similar to what I'm getting at, or know of Lisp
>:tools I could use to build it.

hm... I'd consider Emacs Lisp, which I have played with some:

        1.  Built in string manipulation (strings up to 24MB in length).
        2.  You can use it to edit binary files.
        3.  regular expressions, pattern matching, etc.
        4.  piping is possible, at least (I believe it's possible to use
                emacs as a shell, among other things).
        5.  looks like lisp (well, to me, at least--I'd only used Scheme
                otherwise).

additional benefits:

        1.  GPL.
        2.  Built in editor :)
        3.  interpreted *and* compiled.
        4.  Can be run, and programmed, interactively (like other lisps).
        5.  Manuals on the web (so you can get started now).

Anyway, it's something to consider.  As for its power, remember that a
very goodly portion of Emacs is written directly in Emacs Lisp.

Quote:
>It's been too long for me to recall all that lisp offers -- what kinds of
>data structures are you looking for?  Perl has a pretty rich set of
>first-class data and code thingies, including strings and numbers (even
>bignums), arrays (lists) and associative arrays (alists), objects and
>references and closures, plus some o-o tricks for transparently
>intercepting variable access to transparently trigger user-defined fetch
>and store (etc) methods.  I have a document at http://perl.com/perl/pdsc/
>that starts to talk about some of these in more detail that other perl
>documentation does.
>What other stuff would you be looking for?
>--tom
>--

>    A formal parsing algorithm should not always be used.
>                --D. Gries

--



Wed, 15 Apr 1998 03:00:00 GMT  
 A Lispish Perl?

|> What other stuff would you be looking for?

parentheses ... :-) I mean a clear, regular syntax :-)

:Has anyone tried to write a language (or a set of extensions to Lisp)
:that has the basic functionality of Perl

Well, plenty. I am a bit ashamed of the current state of my FAQ in this
domain (see ftp://koala.inria.fr/pub/EmbeddedInterpretersCatalog.txt), but
I would cite: xlisp ELI ELK J Oscheme and many schemes (SCM,
scheme-48....) see: http://www.cs.indiana.edu/scheme-repository/home.html

with a special mention to mine, "Klone" at ftp://koala.inria.fr/pub/Klone,
and to THE gnu one, "guile" (based on the SCM scheme) that promises to
compete with the "big three" (tcl/perl/python). Klone is a descendant from
Wool use in the X window manager GWM, but different enough to warrant a
new name.

I plan also to set up a web forum to discuss what features are important
in a language, so that all major languages should benefit from what we
learn with our galaxy of experimental ones. Take for instance the last one
I came up with: "unquotable strings" ("raw strings" in Klone)

The idea is to use (optionally) a control-character to quote strings and
not allowing this character inside the string. for Klone it is ^^
(control-caret) as it is visually pleasing. This allows very confortable
"mixed programming" where you deal with a lot of strings to pass to other
string-processing programs, such as HTML browsers for CGI scripting, or
sending to a wish (tcl/Tk) subprocess... think of it: no more escaping
quotes! arent you tired of writing:
         "set a \"foo bar\""
just use:
        ^^set a "foo bar"^^

--



Fri, 17 Apr 1998 03:00:00 GMT  
 A Lispish Perl?

Quote:
> :matching, and string processing) with straightforward Lisp-like syntax

                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
Quote:
> :Lisp, and I wish I could combine their strengths.  Please send mail (I

                            ^^^^^^^^^^^^^^^^^^^^^^^

Hmm, reading in and between the lines, I think he is pretty clearly
saying that he wants something close to the syntax and everyday
semantics and library of Common Lisp, but with the regexps and pipes
and similar scripting language conveniences that Perl offers.  That is
not an unreasonable desire, IMHO.  Many of us want that, too.  In any
case, he explicitly mentioned a straightforward Lisp-like syntax.

Quote:
> It's been too long for me to recall all that lisp offers -- what kinds of

                                                              ^^^^^^^^^^^^^
Quote:
> data structures are you looking for?  Perl has a pretty rich set of

  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Here I think it's fair to say that you did not answer his question.

Let's say for the sake of the discussion that Perl has all the data
structure flexibility of CLOS and more.  Then unless Perl has made
some truly unprecedented changes recently, it is still the case that
its syntax is very different from Lisp.

To me and others, Perl is the most different from Lisp in syntax of
any programming language in widespread use today.  Perhaps to you Perl
and Lisp have similar syntax.  Speaking as somebody who has looked
closely at Perl (before Perl 5) but rejected it almost solely on the
basis of its syntax, I find that an extraordinary opinion!

Perl has many features, even unusual things Lisp has like
multiple-value-setq.  But I would not call its syntax like Lisp.

Quote:
> What other stuff would you be looking for?

I presume that he wants, as many of us do, a Lisp that does easy pipes
and fast regexps.  I would be satisfied with a fast, small CL with
built-in regexps and threads, but know of nothing perfect yet.

In addition to gcl, cmucl, clisp, and commercial Lisps, he might
consider such programs as scsh, guile, various other schemes, emacs
lisp (emacs -batch), and xlisp.  Some of these might require foreign
functions.  Some (the CL's) can implement partial regexps in Lisp
itself.  Some have them built in.  They have varying piping
capabilities and varying startup speeds and sizes.  I happen to prefer
CL, so the progress in speed and Unixisms by scheme compilers is only
relevant to me inasmuch as they have improving CL libraries as well.

Until I get a suitably CLish, fast, small, regexping Lisp, I'm
sticking with zsh and all those little Unix utilities, not Perl, for
most shell scripts, We're not too far away from what we need, and some
(such as some of the above scheme authors) think we're there already.

If you post a followup to this article, please also send a courtesy
verbatim copy by email to help work around potentially unreliable
feeds.

---
Have you learned something today?
                      Have you taught something today?
                                          Have you exercised free speech today?



Sat, 18 Apr 1998 03:00:00 GMT  
 A Lispish Perl?
 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc,

:|> What other stuff would you be looking for?
:parentheses ... :-) I mean a clear, regular syntax :-)

A clear regular syntax?  Ok....

:The idea is to use (optionally) a control-character to quote strings and
:not allowing this character inside the string. for Klone it is ^^
:(control-caret) as it is visually pleasing. This allows very confortable

: think of it: no more escaping
:quotes! arent you tired of writing:
:        "set a \"foo bar\""
:just use:
:       ^^set a "foo bar"^^

So, you're asking for a nice syntax in one breath and going and ADDING
CONTROL CHARACTERS to your language in the next???

Does this seem MIGHTY STRANGE to anyone else but me?

It would seem that the obvious solution for legibility is to use paired
delimiters of your choice to avoid having to escape stuff and so it's easy
to match up.  Traditional languages and even lisp or scheme have always
used brackets for this, although which flavor of bracket has varied.
Certainly tcl proved how useful it was as a quoting mechanism to have
paired curley brackets for single quoting and leave paired square ones for
execution stuff.  This is a fine precedent, don't you think?  I wonder why
no one has does this before?  We just need to be able to do something like
this for double quotes and we're set.

Hm... I have this *absolutely radical* notion.  Let's use a reasonable
functional notation for all our quoting rather than adding more funky
characters.  I'll just use qq() for double quote, so

    qq(set a "foo bar")

would mean a double-quoted string literal, but the embedded double quotes
wouldn't need escaping.  So you could interpolate your variables if you'd
like, as in

    qq(set a "foo $something bar")

And you wouldn't have to escape the double quotes.  Of course, if you had
another round bracket in the inside, it would be a problem just as it
already is in other round, curley, or square bracket expression.

Hmm... let's say you can use ANY bracket type after the qq() stuff.
It's not precisely a real function anyway.  That way you could avoid

    qq(set a "foo $something \( bar")

and instead use

    qq{set a "foo $something ( bar"}
or
    qq[set a "foo $something ( bar"]

Hey, I got another wild idea.  Since we already have this nice
variant qq() notation for double quoting, let's use q() for single
quoting:

    q(set a "i'm not ready")
    q[set a "i'm not ready"]
    q{set a "i'm not ready"}

Nifty!

Another thing that I've always appreciated on one hand and disliked
syntactically on the other is ksh's notation of $(cmd args) notation
instead of `cmd args`, which is certainly confusing.  It's nice that the
round brackets are paired and nest and all for those execution quotes, but
it's sure not very consistent with the way the other quoting stuff we've
been developing works.

Oh, of course.  What *WAS* I thinking!?  It's an eXecutution Quote!

    qx(cmd args)
    qx[cmd args]
    qx{cmd args}

Well, look at that.  I think that takes care of all these funny
pseudo-literals in a nice, clean, regular fashion.  I wonder why
no smart language designer has ever used this before?

I guess they actually have, haven't they?  Must have been that crazy Ken
Thompson guy or something.  I realize that perhaps you lisp people
probably don't realize it, but all the standard UNIX editors have always
tolerated not just the

    s/foo/bar/g

sort of syntax, but also the versatile alternate form of choosing
your own delims to aid in avoiding ugly backslashitis:

    s,foo/bar,other,g

Heck, in vi, you could even say neato stuff like

    s!\(foo\)/\(bar\)!\u\1/xxx/\u\2!g

Ugly those it is, it's sure useful.  
Too bad it wouldn't have been the far more legible

    s!(foo)/(bar)!\u\1/xxx/\u\2!g
    s(foo/bar)(\u&)g
    s((foo)/(bar))(\u\1/xxx/\u\2)g

or even

    s[(foo)/(bar)][\u\1/xxx/\u\2]g
    s[(foo/bar)][\u\1]g

You know, like the way it works in tr:

    tr[a-z][A-Z]

or our fine q(), qq(), and qx() pseudo-literals that we just,
er, invented. :-)

--tom
--

You have made an excellent hit on the UNIX.--More--



Sun, 19 Apr 1998 03:00:00 GMT  
 A Lispish Perl?

   : think of it: no more escaping
   :quotes! arent you tired of writing:
   :     "set a \"foo bar\""
   :just use:
   :    ^^set a "foo bar"^^

   It would seem that the obvious solution for legibility is to use paired
   delimiters of your choice to avoid having to escape stuff and so it's easy
   to match up.  Traditional languages and even lisp or scheme have always
   used brackets for this, although which flavor of bracket has varied.

   Hm... I have this *absolutely radical* notion.  Let's use a reasonable
   functional notation for all our quoting rather than adding more funky
   characters.  I'll just use qq() for double quote, so

       qq(set a "foo bar")

This is far more offensive (to me) than just using the \ to escape embed "'s.

I am not tired of writing:
          "set a \"foo bar\""
but I would be truly nauseous if I had to, instead, type:
       qq(set a "foo bar")
or any other intrusive notation that obscures the meaning.

How does this stike you:

 "foo bar ``baz snark'' quux"

where the `` and '' get magically re-written into:

 "foo bar \"baz snark\" quux"

Far less kludgey than what you proposed but if your hell-bent on eliminating
the \" then this at least is no more characters the \' and it also does not
require use of the SHIFT key to generate parens (on my keyboard).

So what if you want to embed a `` or '' literally within your strings?

Easy...

#     #
#  #  #  #    #   ####
#  #  #  #    #  #    #
#  #  #  ######  #    #
#  #  #  #    #  #    #
#  #  #  #    #  #    #
 ## ##   #    #   ####

 #####                                    ###     ###
#     #    ##    #####   ######   ####    ###     ###
#         #  #   #    #  #       #        ###     ###
#        #    #  #    #  #####    ####     #       #
#        ######  #####   #            #
#     #  #    #  #   #   #       #    #   ###     ###
 #####   #    #  #    #  ######   ####    ###     ###

 Love,
 ziggy

(chuckle)

--
------------------------------------------------------------------------------


,,Lambda Calculus...   /\\_ ...uber alles!'' | 545 Technology Square--Room 439
http://www-swiss.ai.mit.edu/~ziggy/ziggy.html| Cambridge,  MA USA   02139-3594



Sun, 19 Apr 1998 03:00:00 GMT  
 A Lispish Perl?
Scheme. Perl!  scheme-perl?

Here's an interesting solution to the original request for a lispish
perl.  From the depts of the Perl Archives: sp.pl

One of these days I'll get around to porting this to perl5 --
"my" should make the code a heck of a lot simpler...  How about
implementing a MOP in scheme-perl?

'Zed

 --------

Subject: Scheme in Perl? (sp?):  The Code.  Part 1 of 2.
Date: 19 Nov 90 07:55:09 GMT

Followup-To: comp.lang.perl
Organization: Penn State Computer Science
Lines: 1245
Xref: tut.cis.ohio-state.edu comp.lang.perl:3041 alt.sources:2570
Nntp-Posting-Host: guardian.cs.psu.edu

Just what you've all been waiting for, a Scheme interpreter written in
Perl.  See the Blurb, in a separate article (in comp.lang.perl).


#!/usr/bin/perl
# Scheme in Perl? (sp?)
# Public domain. No strings attached.

($version) = '$Revision: 2.6 $' =~ /: (\d+\.\d+)/;

#------
#-- Basic data types.
#------

# There are three places that know about data type representation:
# 1. The &TYPE function.
# 2. The basic functions for that type in this section.
# 3. The equivalence routines (eq?, eqv?, and equal?).
# Any change in representation needs to look at all these.

%TYPEname = ();

sub TYPES {
        local($k);



        }

Quote:
}

&TYPES( $T_NONE,    'nothing',
        $T_NIL,         'a null list',
        $T_BOOLEAN,     'a boolean',
        $T_NUMBER,      'a number',
        $T_CHAR,        'a character',
        $T_STRING,      'a string',
        $T_PAIR,        'a pair',
        $T_VECTOR,      'a vector',
        $T_TABLE,       'a table',
        $T_SYMBOL,      'a symbol',
        $T_INPUT,       'an input port',
        $T_OUTPUT,      'an output port',
        $T_FORM,        'a special form',
        $T_SUBR,        'a built-in procedure',
        # Some derived types.  See &CHKtype.
        $T_LIST,        'a list',
        $T_PROCEDURE,   'a procedure',
        $T_ANY,         'anything');

# Scheme object -> type.
sub TYPE {

        if    (/^$/)    { $T_NIL; }
        elsif (/^[01]/) { $T_BOOLEAN; }
        elsif (/^N/)    { $T_NUMBER; }
        elsif (/^C/)    { $T_CHAR; }
        elsif (/^Z'S/)  { $T_STRING; }
        elsif (/^Z'P/)  { $T_PAIR; }
        elsif (/^Z'V/)  { $T_VECTOR; }
        elsif (/^Z'T/)  { $T_TABLE; }
        elsif (/^Y/)    { $T_SYMBOL; }
        elsif (/^FORM/) { $T_FORM; }
        elsif (/^SUBR/) { $T_SUBR; }
        elsif (/^Z'IP/) { $T_INPUT; }
        elsif (/^Z'OP/) { $T_OUTPUT; }
        else            { $T_NONE; }

Quote:
}

#-- More derived types.

# A closure is a vector that looks like
#       #(CLOSURE env listarg nargs arg... code...)
# See &lambda and &applyN.
$CLOSURE = &Y('CLOSURE');

# A promise is a vector that looks like
#       #(PROMISE env forced? value code...)
# See &delay and &force.
$PROMISE = &Y('PROMISE');

#-- Booleans.

# Scheme booleans and Perl booleans are designed to be equivalent.

$NIL = '';
$TRUE = 1;
$FALSE = 0;

#-- Numbers.

# Perl number -> Scheme number.
sub N {

Quote:
}

# Scheme number -> Perl number.
sub Nval {

        $';

Quote:
}

#-- Characters.

# Perl character -> Scheme character.
sub C {

Quote:
}

# Scheme character -> Perl character.
sub Cval {

        $';

Quote:
}

#-- Strings.
# Strings are encapsulated so that eqv? works properly.

# Perl string -> Scheme string.
sub S {

        local(*s) = local($z) = "Z'S" . ++$Z'S;
        $s = $sip;
        $z;

Quote:
}

# Scheme string -> Perl string.
sub Sval {


        $s;

Quote:
}

# Scheme string <= start, length, new Perl string.
sub Sset {



        substr($s, $p, $l) = $n;

Quote:
}

#-- Pairs and lists.

# Perl vector (A, D) -> Scheme pair (A . D).
sub P {

        local(*p) = local($z) = "Z'P" . ++$Z'P;

        $z;

Quote:
}

# Scheme pair (A . D) -> Perl list (A, D).
sub Pval {



Quote:
}

# Scheme pair (sexp0 . sexp1) <= index, new Scheme value.
sub Pset {




Quote:
}

# Perl vector -> Scheme list.
sub L {

        local($list) = $NIL;


        $list;

Quote:
}

# Scheme list -> Perl vector.  XXX Doesn't do improper or recursive
lists.
sub Lval {


        while ($list ne $NIL) {
                ($x, $list) = &Pval($list);

        }

Quote:
}

#-- Vectors.

# Perl vector -> Scheme vector.
sub V {

        local(*v) = local($z) = "Z'V" . ++$Z'V;

        $z;

Quote:
}

# Scheme vector -> Perl vector.
sub Vval {



Quote:
}

# Scheme vector <= start, length, new Perl vector.
sub Vset {




Quote:
}

#-- Tables.

# XXX Tables could use a "default value".

# -> Scheme table.
sub T {
        "Z'T" . ++$Z'T;

Quote:
}

# Scheme table, Scheme symbol -> Scheme value.
sub Tval {



        $t{$'};

Quote:
}

# Scheme table <= Perl string, new Scheme value.
sub Tset {





Quote:
}

# Scheme table -> Perl vector of keys.
sub Tkeys {


        keys %t;

Quote:
}

#-- Symbols.

%OBLIST = ();
$OBLIST = &REF("Z'Toblist", 'OBLIST');

# Perl string -> Scheme symbol.
sub Y {

Quote:
}

# Scheme symbol -> Perl string.
sub Yname {

        $';

Quote:
}

# Scheme symbol -> global Scheme value.
sub Yval {

        $OBLIST{$'};

Quote:
}

# Scheme symbol <= new global Scheme value.
sub Yset {


Quote:
}

# Perl string symbol name <= new global Scheme value.
sub DEF {

Quote:
}

# Create an aliased object.
sub REF {



        $a;

Quote:
}

&SUBR0('global-environment');
sub global_environment {
        $OBLIST;

Quote:
}

#-- Input and output ports.

%IPbuffer = ();

# Perl string filename -> Scheme input port.
sub IP {

        local($z) = "Z'IP" . ++$Z'IP;
        open($z, "< $f\0") || return $NIL;
        $IPbuffer{$z} = '';
        $z;

Quote:
}

# Scheme input port -> Perl filehandle.
sub IPval {


Quote:
}

# Scheme input port => Perl string.
sub IPget {


        local($_) = $IPbuffer{$ip};
        $_ ne '' ? ($IPbuffer{$ip} = '') : ($_ = <$ip>);
        $_;

Quote:
}

# Like &IPget, but skip leading whitespace and comments.
sub IPgetns {


        local($_) = $IPbuffer{$ip};
        $_ ne '' ? ($IPbuffer{$ip} = '') : ($_ = <$ip>);
        $_ = <$ip> while $_ ne '' && /^\s*;|^\s*$/;
        s/^\s+//;
        $_;

Quote:
}

# Scheme input port <= Perl string.
sub IPput {


Quote:
}

# Perl string filename -> Scheme output port.
sub OP {

        local($z) = "Z'OP" . ++$Z'OP;
        open($z, "> $f\0") || return $NIL;
        $z;

Quote:
}

# Scheme output port -> Perl filehandle.
sub OPval {


Quote:
}

# Scheme output port <= Perl string.
sub OPput {




Quote:
}

sub IOinit {
        open($stdin  = "Z'IPstdin",  "<& STDIN");
        open($stdout = "Z'OPstdout", ">& STDOUT");
        open($stderr = "Z'OPstderr", ">& STDERR");
        select($stderr); $| = 1;
        $ttyin  = &IP('/dev/tty');
        $ttyout = &OP('/dev/tty');

Quote:
}

sub IOshutdown {
        close($stdin);
        close($stdout);
        close($stderr);
        close($ttyin);
        close($ttyout);

Quote:
}

&SUBR0('standard-input');  sub standard_input  { $stdin;  }
&SUBR0('standard-output'); sub standard_output { $stdout; }
&SUBR0('standard-error');  sub standard_error  { $stderr; }
&SUBR0('terminal-input');  sub terminal_input  { $ttyin;  }
&SUBR0('terminal-output'); sub terminal_output { $ttyout; }

#-- Special forms.

# Define Scheme special form <= name.
sub FORM {

        $sub =~ tr/->?!*/_2PIX/;
        &DEF($name, 'FORM' . $sub);

Quote:
}

# Scheme special form -> Perl subroutine name.
sub FORMval {

        $';

Quote:
}

#-- Builtin functions (subrs).

%SUBRmin = ();
%SUBRmax = ();
%SUBRtypes = ();

# Define Scheme builtin <= name, minargs, maxargs, type list.
sub SUBR {


        local($sub) = $name;
        $sub =~ tr/->?!*/_2PIX/;
        $SUBRmin{$sub} = $min;
        $SUBRmax{$sub} = $max;

        &DEF($name, 'SUBR' . $sub);

Quote:
}

# Scheme builtin function -> Perl sub name, minargs, maxargs, type list.
sub SUBRval {

        ($', $SUBRmin{$'}, $SUBRmax{$'}, unpack('L*', $SUBRtypes{$'}));

Quote:
}

# Some convenient aliases...
sub SUBR0 { &SUBR(shift, 0, 0); }




# A convenient macro...
sub CMP_SUBR {


        local($s) = &SUBR($longname, 0, -1, $type);
        &DEF($name, $s);
        eval 'sub ' . (&SUBRval($s))[0] . ' {

                local($r) = 1;


                }
                $r;
        }';

Quote:
}

#-- Miscellany.

&SUBR0('*show-memory-use');
sub Xshow_memory_use {
        print $stderr 'memory use: s', $Z'S+0, ' p', $Z'P+0, ' v', $Z'V+0;
        print $stderr ' t', $Z'T+0, ' ip', $Z'IP+0, ' op', $Z'OP+0;
        print $stderr
...

read more »



Mon, 20 Apr 1998 03:00:00 GMT  
 A Lispish Perl?
For the Scheme Shell I borrowed a trick from LaTeX's \verb command and most
shell's "here documents" (the <<EOF redirection mechanism for including
constant data to be presented on a file descriptor).

You can write long string constants with strange constituent characters
in scsh using "here strings." There are two kinds of here string:
character delimited, and line delimited.

A character-delimited here string looks like

        #<|"She's forgotten the \verb command, again," said James.|

The syntax is
        - sharp, less than,
        - a delimiter character of your choice,
        - the string,
        - the delimiter character.
There is absolutely no interpretation of the chars between your
delimiters. Backslashes, double quotes, single quotes -- whatever. It's all
just taken verbatim. The example above is *exactly* equivalent to writing

        "\"She's forgotten the \\verb command, again,\" said James."

in Scheme, and you can write either in scsh, interchangeably.

The one character you may not use as a delimiter in a character-delimited
here string is "<". This is used to introduce line-delimited here strings.
A line-delimited here string looks like this:

        #<<Casey at the bat
        The outlook wasn't brilliant,
        For the Mudville Nine that day,
        The score stood two to four,
        With but one inning more to play.
        Casey at the bat

The syntax is
        - sharp, double less than,
        - a delimiter line,
        - the string,
        - the delimiter line.
Again, no interpretation at all of interior characters.  (I chose not to get
into the complexities of somehow embedding variable substitution expressions
inside the strings, as shells allow. The Scheme solution is to embed ~a's and
then use the string in a FORMAT expression.)

These syntaxes are covered in a little more detail in the scsh manual.
I added them to the language to make it easier to write long, multi-line
strings, such as chunks of text written in other languages (e.g., Awk,
or sed, or grep, or Perl), inside scsh scripts. Having to apply all
the Scheme string conventions for escaping the right magic characters
would have been obfuscatory and error prone, so I made this alternate
mechanism.

Here strings are new in release 0.4; I have no idea if people will like them.
You can pick up the sources or the manual for the new release at
    http://www-swiss.ai.mit.edu/scsh/scsh.html
        -Olin



Mon, 20 Apr 1998 03:00:00 GMT  
 A Lispish Perl?

Quote:
> For the Scheme Shell I borrowed a trick from LaTeX's \verb command and most
> shell's "here documents" (the <<EOF redirection mechanism for including
> constant data to be presented on a file descriptor).
> [...]
> A character-delimited here string looks like

>    #<|"She's forgotten the \verb command, again," said James.|

> The syntax is
>    - sharp, less than,
>    - a delimiter character of your choice,
>    - the string,
>    - the delimiter character.
> There is absolutely no interpretation of the chars between your
> delimiters. Backslashes, double quotes, single quotes -- whatever. It's all
> just taken verbatim. The example above is *exactly* equivalent to writing

I have to say, python's triple-quote for line-spanning strings is, in my
experience, the most effective mechanism of this sort that i've used.
Perhaps i've been following this too loosely, but it seems like it would
be suitable for the situations concerning you all.

The *only* time i encounter the need to escape characters within the
string is when i'm embedding an extended string within another, eg to
express a python code fragment which contains an extended string.  And
then it's easy to escape one of the three quotes, and the embedding is
(fairly) obvious.  I think that *not* using an arbitrary delimiter
character is an advantage, because you don't need to see the start of the
string to be able to see the end...

Perhaps the differences of not being a shell-command execution
environment has different, and less strenuous demands, however.


        Corporation for National Research Initiatives
                1895 Preston White Drive, Suite 100
                        Reston, VA 22091



Mon, 20 Apr 1998 03:00:00 GMT  
 A Lispish Perl?

 ET> Scheme. Perl!  scheme-perl?
 ET> Here's an interesting solution to the original request for a lispish
 ET> perl.  From the depts of the Perl Archives: sp.pl

Hey, that's some way-cool code.  I have only one question: Why? :-)

Michael.



Tue, 21 Apr 1998 03:00:00 GMT  
 
 [ 12 post ] 

 Relevant Pages 

1. A Lispish Perl?

2. NYC: PERL PERL PERL PERL PERL PERL PERL

3. Perl, perl or PERL debate

4. Perl Golf mailing list - perl.golf on nntp.perl.org

5. Perl, Perl, Perl, don't give your love to URL

6. RFD - comp.lang.perl.db, comp.lang.perl.network, comp.lang.perl.regex

7. \c@ in Perl, perl & perl + modules

8. New dialect of perl: xperl (or reinventing perl, or perl-izing jpython)

9. Perl/Swing (Perl/AWT) as an eventual alternative to Perl/Tk

10. Perl *is* strongly typed (was Re: Perl description)

11. Perl syntax and beyond (was: Re: Perl style and module searches)

12. Perl 6, llya, and lisp as a replacement for Perl

 

 
Powered by phpBB® Forum Software