From: Mark Miller <markm@caplet.com>
Replying To: Chris Hibbert <chris@pancrit.org>
Date: Mon, 11 Nov 2002 12:18:07 -0800
Subject: Re: [e-lang] quasi-questions

At 07:59 PM 11/10/2002 Sunday, Chris Hibbert wrote:
>I'm using quasi-literals for the e program I'm currently playing with, and 
>I've started to think that quasi-patterns might make more sense than what 
>I'm currently doing with split().  

Very plausible.   I often write code using the pattern:

    def doSomething(var text :String) ...  {
        while (text =~ `@left...sub-pattern...@rest`) {
            # where "...sub-pattern..." may contain more @-holes
            # ... do something left and other bound variables besides rest
            text := rest
        }
        # ... do something with text, which at this point is the remainder of 
        # the original text that occurs after the last occurrence of the
        # ...sub-pattern...
    }

When "...sub-pattern..."  is just literal text, then this loop is equivalent to
a for-loop using split, and the for-loop is easier to read, as the 
"...do something" occurs only once:

    for part in text.split(separator) {
        # ...  do something with part
    }

so I'd use split for these degenerate cases. 


>There are a few paragraphs on quasi-things in Walnut; they refer to an 
>example web server, which I haven't found.

It's in the source tree at src/esrc/scripts/webServer/webServerSocket80.e.
Btw, it's only 123 lines of code. 


>"quasi" appears in the ELib API 
>in a few places, which led me to the elang grammar doc 
>(http://www.erights.org/elang/grammar/quasi-overview.html), which gives more 
>examples of use of quasi-literals and -matchers.  It also refers to 
>parseUpdoc.emaker as a source of more examples, but I couldn't find it.  I 
>found makeUpdocParser.emaker instead, but it didn't seem relevant.

I have now updated that document to reflect reality.  The relevant part now reads 

>A good example of readable code using regular expressions can be found in 
>the old "parseUpdoc.emaker" before 
>http://www.eros-os.org/pipermail/e-lang/1999-April/002555.html and after 
>http://www.eros-os.org/pipermail/e-lang/1999-April/002570.html using "(?x)". 
>In any case, the current updoc parser, in makeUpdocParser.emaker in the 
>source tree, no longer uses the rx__quasiParser. We think it's more readable 
>without it, but YMMV.

More later... 


----------------------------------------
Text by me above is hereby placed in the public domain

        Cheers,
        --MarkM

_______________________________________________
e-lang mailing list
e-lang@mail.eros-os.org
http://www.eros-os.org/mailman/listinfo/e-lang