It's on separate keys, far apart on the keyboard,
and one of them requires shift and one of them
requires non-shift.
Does it have value beyond its historicity? Is it
one of Paul Graham's "Onions?" Would there be a
problem in a Lisp where characters were single-quote
delimited as in other languages and the backslash
was used for quoting? It would look a lot less like
Martian to most programmers.
Bear
I agree that the #\x syntax sucks for the most part.
I thought about it and found no satisfying solution.
Single quotes are problematic in lisp/scheme. What
does 'a'a lex as?
Is it [#\a a]? Or is it [quote a quote a]?
Or were you thinking that the quote in 'a should go
away and be replaced by \a?
Aziz,,,
I was thinking that \a should be syntax for (quote a)
and that 'a should not be.
Then, I'd take the ' character and use it for
delimiting character constants, so I'd be writing
'a' instead of #\a. So your example
'a'a would be either a syntax error (trailing
delimiter required after character constant) or
it would parse the same as current lisps parse
#\a a.
Bear
Agreed.
> It's on separate keys, far apart on the keyboard,
> and one of them requires shift and one of them
> requires non-shift.
Yes, this is true on dvorak as well. As a half-assed work-around,
consider making a macro in your editor of choice. (I have a shortcut for
typing lambda (which emacs can display as the greek character, so it's
even shorter than 'fn'.))
> Does it have value beyond its historicity?
Yes, one valuable aspect is that it works for all characters.
Consider:
#\\
#\'
Another is that it's always self-evaluating.
A third is that the concatenation of #\# and another character is
standard syntax in lisp for non-sexp:y stuff. #' in CL comes to mind.
> It would look a lot less like
> Martian to most programmers.
But we are on Mars, figuratively speaking. The #\c construct is afaik
older than the 'c' one.
That said, I'm not fundamentally opposed to seeing a lisp which uses the
'c' construct, possibly in conjunction with another syntax for (quote).
I don't like \( because it's a "false friend" to "non-Martians"; a
non-Martian could parse that as "This paren doesn't need to close" or
something like that.
To clarify:
It is possible in theory to have a lisp where:
'a' is #\a
and
'a is the symbol a
For people who want to play with this:
http://www.call-with-current-continuation.org/manual/Reader-extensions.html
and/or CL read-tables
> The combination #\ is annoying and hard to type.
i don't write enough literal chars to care, but if you really really
really must:
CL-USER> (defun read-char-for-macro-char (stream char)
(declare (ignore char))
(read-char stream))
READ-CHAR-SANS-SHIFT-CHARS
CL-USER> (set-macro-character #\^ #'read-char-for-macro-char nil)
T
CL-USER> ^a
#\a
CL-USER>
it's easiest if you chose a single prefix char, parsing '<char>' (with
different semantics depending on what comes after the char) is doable
but i'll leave that as a excercise.
--
-Marco
Ring the bells that still can ring.
Forget the perfect offering.
There is a crack in everything.
That's how the light gets in.
-Leonard Cohen
>
> The combination #\ is annoying and hard to type.
>
> It's on separate keys, far apart on the keyboard,
> and one of them requires shift and one of them
> requires non-shift.
Who cares? For obvious reasons, in emacs, I've switched
the $ key and the ` key when I'm programming perl.
This is also possible for the #\ combination.
>
> was used for quoting? It would look a lot less like
> Martian to most programmers.
I personally like #\...
> The combination #\ is annoying and hard to type.
You want this for a new language right? So why not forget about characters and
use strings?
'as
> It's on separate keys, far apart on the keyboard,
> and one of them requires shift and one of them
> requires non-shift.
Differently shifted on _your_ keyboard, not on mine. I suggest you
fix your keyboard. Or of course your reader, which is fairly easy to
do for the inhabitants of one half of the groups you posted to:
;; I believe @ and \ are both unshifted on US keyboards
(make-dispatch-macro-character #\@ t)
(set-dispatch-macro-character #\@ #\\
(get-dispatch-macro-character #\# #\\))
(type-of @\e)
but since for me typing #\ isn't a problem...
Followups set.
Christophe
> The combination #\ is annoying and hard to type.
I agree and add: and ugly.
That's why I always write: (character "x") instead of #\x
(And if you did not notice, I also use (function x) instead of #'x
and I may use (quote x) instead of 'x slightly more often than other
contemporary lisp programmers).
But I guess you'll rather like Marco's macro char; only use ? instead
of ^, since that's what emacs uses.
--
__Pascal Bourguignon__ http://www.informatimago.com/
Nobody can fix the economy. Nobody can be trusted with their finger
on the button. Nobody's perfect. VOTE FOR NOBODY.
> I was thinking that \a should be syntax for (quote a)
> and that 'a should not be.
>
> Then, I'd take the ' character and use it for
> delimiting character constants, so I'd be writing
> 'a' instead of #\a.
I'm all for it. It would help people transition to s-expr syntax more
easily. Since there's always one character between the single quotes,
''' could even be valid. The #\ syntax could be kept for numeric
character constants.
--
http://ourdoings.com/ Let your digital photos organize themselves.
Sign up today for a 7-day free trial.
| That's why I always write: (character "x") instead of #\x
Write that as #.(character "x") and the irony is palpable.
Ah, the things we do for our good looks.
--
* Harald Hanche-Olsen <URL:http://www.math.ntnu.no/~hanche/>
- Debating gives most of us much more psychological satisfaction
than thinking does: but it deprives us of whatever chance there is
of getting closer to the truth. -- C.P. Snow
Ack. And while we're at revolutionizing the language, let's include
standard C notation for characters and strings.
"Hi\n\tthere" and the like. It sucks that newline is #\newline, not a
\n in a string.
> Ack. And while we're at revolutionizing the language, let's include
> standard C notation for characters and strings.
>
> "Hi\n\tthere" and the like. It sucks that newline is #\newline, not
> a \n in a string.
It's there if you want it:
<http://weitz.de/cl-interpol/>
I don't use it myself, though. Go figure...
Edi.
--
Lisp is not dead, it just smells funny.
Real email: (replace (subseq "spam...@agharta.de" 5) "edi")
what about backspace, return, tab etc?
--
Coby Beck
(remove #\Space "coby 101 @ big pond . com")
> "Bruce Lewis" <brl...@yahoo.com> wrote in message
> news:nm9fyzl...@biohazard-cafe.mit.edu...
> >
> > I'm all for it. It would help people transition to s-expr syntax more
> > easily. Since there's always one character between the single quotes,
> > ''' could even be valid. The #\ syntax could be kept for numeric
> > character constants.
>
> what about backspace, return, tab etc?
Two alternative ideas:
(1) Use #\ for those too.
(2) #\[ ==> '['
#\tab ==> '[tab]'
#\newline ==> '[newline]'
etc.
The second bit adds a little complexity to the parser, but in the 30
seconds I've invested into this idea I haven't come up with likely
scenarios of ambiguities / confusing error messages it would cause.
I think that with opening and closing singlequotes, you can use
character names as easily as character literals. So instead of
having a situation where there's always one character between
the single quotes and ''' is valid, I'd have character names
between single quotes, and most keyboard characters have a name
that's one character long. But a few exceptions would exist,
so valid characters would look like
'a' 'b' 'c'
'backspace' 'singlequote' 'return' '\' '@', and so on.
It even gives you a nice typeable interface to unicode characters,
where you can use the unicode names directly and say things like
'latin lowercase a with accent grave'
Of course you'd probably want a way to define shorter character
names for them.
Bear
Ray Dillinger schrieb:
[...]
> Of course you'd probably want a way to define shorter character
> names for them.
That is called "Icon". Right?
stefan
> Ray Dillinger schrieb:
>>Of course you'd probably want a way to define shorter character
>>names for them.
> That is called "Icon". Right?
> stefan
Sorry, I don't know what Icon is. Can you elaborate?
Bear