Subject: Re: How to simulate currying?
From: rpw3@rpw3.org (Rob Warnock)
Date: Thu, 19 Feb 2009 23:20:28 -0600
Newsgroups: comp.lang.lisp
Message-ID: <jbmdnSsqUK0BoAPUnZ2dnUVZ_qrinZ2d@speakeasy.net>
Tobias C. Rittweiler <tcr@freebits.de.invalid> wrote:
+---------------
| Chris Riesbeck <...> writes:
| > For contrast, here's a straight macro version. Every _ is replaced by
| > a gensym, every _n is replaced by a previous _ variable
| > (one-based). Any other use of _xxx is left alone.
| 
| As a side note, notice that tokens like _1, &c fall under
| implementation-dependent realms as they're potential numbers. 
| See CLHS 2.3.1.1.
+---------------

Thanks for reminding us of that obscure little tidbit!  ;-}

By the way, is the term "extension character" defined *anywhere*
in the CLHS other than parenthetically in passing on page 2.3.1.1?!?
[A massive "grep" suggests it is not. It's certainly not in the
Glossary!!] And is it *ever* any other character besides caret (^)
or underscore (_)?

Also, note that CLHS 2.3.1.1.2 permits -- but does not require --
a conforming implementation to define the meaning of tokens that
are potential numbers but actually numbers. CMUCL, for one example,
defines them as symbols, but always prints them using the multiple-
escape syntax [just so you know you're being naughty? ;-} ], e.g.:

    cmu> (defun foo (x)          
	   (let ((v (read-from-string x)))
	     (format t "~s is a ~a~%" v (type-of v))
	     (values)))

    FOO
    cmu> (foo "1b5000")   ; Note the multiple escapes.
    |1B5000| is a SYMBOL
    cmu> (foo "777777q")  ; Ditto.
    |777777Q| is a SYMBOL
    cmu> (foo "777$")     ; None here, since $ is not an extension character.
    777$ is a SYMBOL
    cmu> (foo "$1")       ; Nor here.
    $1 is a SYMBOL
    cmu> (foo "_1")       ; Oops.
    |_1| is a SYMBOL
    cmu> 

So the "_1" tokens will work [but may print funny!] in any
implementation which makes symbols of potential numbers,
but in any case they're not completely portable.

Hmmm... Assessing the risk...

Does anyone know of an implementation that *does* implement
some sort of "extended numbers" using "^" and/or "_"? 

And does anyone know of an implementation that *doesn't* treat
potential numbers that aren't actually numbers as symbols?


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607