On Wed, Sep 21, 2016 at 08:11:09AM -0400, David A. Wheeler wrote:
>Okay.  Clojure uses {...} for hashes, so newLisp isn't the only Lisp where {}
>has another meaning.  The question is, how should infix be handled?
>It really needs some paired characters, and (...) are spoken for.
>Does newLisp already assign [...] a meaning?

newLisp uses [...] for the tag pairs previous mentioned [cmd] and [text], and
the parser doesn't allow [ to be used as first character of a symbol.

For dictionaries, newLisp does it like this:

(define d:d) ; define d as a dictionary
(d a b)      ; assigns b to a in dictionary d
(d a)        ; looks up a in d, returns the value

Dictionaries are first class objects in newlisp, but they don't nest.  They are
all defined and stored at the top level, called MAIN.  This is for garbage
collection reasons.

>If so, the best approach may be to use
>«x + 1» : Left/right-pointing double-angle quotation mark, U+AB/U+BB. These 
>are very well-supported (e.g., they are used for French quotations and are in 
>Latin-1), and in many cases are the easiest to enter. There is a risk of them 
>being too similar to the comparison operators < and >, but this doesn't seem 
>too bad. Nested example: fact«n * «n - 1»»
>I discuss this here:

I suppose I could define a function that swaps the first 2 arguments then
evaluates.  In newlisp, this won't cause any slowdown.  Then infix would look
like this (similar to bourne shell [ function)

> (define-macro (infix a b) (eval (extend (list b a) (args))))
(lambda-macro (a b) (eval (extend (list b a) (args))))
> (if (infix 1 = 2) 5 10)
> (if (infix 1 = 1) 5 10)

ColorForth distinguishes between immediate and compiled words... be nice to
have that distinction in Lisp.  Then a symbol could behave like this at compile 

(a = b) => (apply = (a b))

(a = b or c > d) => (apply or (apply = (a b)) (apply > (c d)))

Then we get into C style precedence rules.

Since infix notation is really useful mostly for mathematical and logical
comparisons, perhaps defining "m" for "math" would have to do the job for
infix.  Where "m" is a full interpreter with precedence rules etc.

(if (m a = b or c > d) e f)

>> Also, newlisp source code is in UTF-8.  Is sweeten UTF-8 compatible?
>It's *supposed* to be, as long as the underlying Scheme is.  It probably
>hasn't been adequately tested that way, but if it's not, it's a bug and needs
>to be fixed.

I have some source code I can test it on.  UTF-8 lets me use mathematical
symbols like "delta" and "differential" and theta, phi, and pi from high school


Readable-discuss mailing list

Reply via email to