Re: String syntax, or Transient Symbol syntax

2014-11-26 Thread Alexander Burger
On Wed, Nov 26, 2014 at 09:50:45AM +0100, Axel Svensson wrote:
> I once wrote my own top-level REPL, if I remember correctly it was
> compatible with picolisp syntax but also had the capability of adding
> reader macros in the way OP desires. Let me know if you're interested, as
> it might take me a while to dig it up.

Or, you might take a look at the 'repl' function in the PicoLisp GUI in
"lib/form.l", and modify that. It runs a REPL in a browser form.

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: String syntax, or Transient Symbol syntax

2014-11-26 Thread Axel Svensson
I once wrote my own top-level REPL, if I remember correctly it was
compatible with picolisp syntax but also had the capability of adding
reader macros in the way OP desires. Let me know if you're interested, as
it might take me a while to dig it up.

On Wed, Nov 26, 2014 at 8:05 AM, Alexander Burger 
wrote:

> Hi Dave,
>
> > I am having some trouble working with Strings or Transient Symbols.
> > (I'll call them strings for now.)
> > ...
> >   "^(a+)\)"
> > In picoLisp, I must enter that as:
> >   "\^(a+)\\)"
>
> That's right. This is the syntax of the PicoLisp reader.
>
>
> > See, the escaping syntax is a pretty heavy burden for the types of
> strings I work with...
> >
> > So, I considered using a reader macro.  I imagined something like:
> >
> >   (re-handler /^(a+)(.*)'.*(\)+)/ "nd here's some input! :")
> > -->
> >   (re-handler "\^(a+)(.*)'.*(\\)+)" "nd here's some input!
> :")
>
> A read macro won't help, because it is still based on 'read', the
> PicoLisp reader synax. A read macro reads an expression, evaluates it,
> and returns the result to the reader.
>
>
> > ..Then I discovered that we don't have a defmacro. (I've read previous
> > discussion about macros and I accept Alex's stance.)
>
> A macro won't help either, because it also processes the data *after*
> they are read by the Lisp reader. And though you can do everything a
> macro would do in PicoLisp with a normal function, it also operates on
> s-expressions and not on the input stream.
>
>
> > Any advice for implementing some sort of special case for /strings/,
> > which would be just like "strings" but with different escape mechanics?
>
> On the *application* level, you can do everything you like, using
> low-level I/O functions like 'char' and 'line'.
>
> I think the problem is that you want to change the *language* level, and
> the reader is the core of the language (read/eval/print).
>
>
> > I see src64/io.l contains (code 'readA_E) which handles reading
> > "strings". But I don't understand this assembly code.
>
> Yes, that's the right place to change the language :)
>
>
> The normal REPL (i.e. the 'load' function) doesn't operate on raw input
> data.
>
> What you could do is write you own top-level REPL, using e.g. 'line' and
> 'eval' directly. Another possibility is using 'pipe' and perhaps
> external tools to process the input stream. In any case you need to get
> hold of the data and process them *before* they are seen by the reader.
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: String syntax, or Transient Symbol syntax

2014-11-25 Thread Alexander Burger
Hi Dave,

> I am having some trouble working with Strings or Transient Symbols.
> (I'll call them strings for now.)
> ... 
>   "^(a+)\)"
> In picoLisp, I must enter that as:
>   "\^(a+)\\)"

That's right. This is the syntax of the PicoLisp reader.


> See, the escaping syntax is a pretty heavy burden for the types of strings I 
> work with...
> 
> So, I considered using a reader macro.  I imagined something like:
> 
>   (re-handler /^(a+)(.*)'.*(\)+)/ "nd here's some input! :")
> -->
>   (re-handler "\^(a+)(.*)'.*(\\)+)" "nd here's some input! :")

A read macro won't help, because it is still based on 'read', the
PicoLisp reader synax. A read macro reads an expression, evaluates it,
and returns the result to the reader.


> ..Then I discovered that we don't have a defmacro. (I've read previous
> discussion about macros and I accept Alex's stance.)

A macro won't help either, because it also processes the data *after*
they are read by the Lisp reader. And though you can do everything a
macro would do in PicoLisp with a normal function, it also operates on
s-expressions and not on the input stream.


> Any advice for implementing some sort of special case for /strings/,
> which would be just like "strings" but with different escape mechanics?

On the *application* level, you can do everything you like, using
low-level I/O functions like 'char' and 'line'.

I think the problem is that you want to change the *language* level, and
the reader is the core of the language (read/eval/print).


> I see src64/io.l contains (code 'readA_E) which handles reading
> "strings". But I don't understand this assembly code.

Yes, that's the right place to change the language :)


The normal REPL (i.e. the 'load' function) doesn't operate on raw input
data.

What you could do is write you own top-level REPL, using e.g. 'line' and
'eval' directly. Another possibility is using 'pipe' and perhaps
external tools to process the input stream. In any case you need to get
hold of the data and process them *before* they are seen by the reader.

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe