Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

character syntax revisited

0 views
Skip to first unread message

Ray Dillinger

unread,
Feb 23, 2005, 11:08:44 PM2/23/05
to

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.

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

Abdulaziz Ghuloum

unread,
Feb 23, 2005, 11:25:53 PM2/23/05
to


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,,,

Ray Dillinger

unread,
Feb 23, 2005, 11:43:22 PM2/23/05
to
Abdulaziz Ghuloum wrote:
> Ray Dillinger wrote:
>
>>
>> The combination #\ is annoying and hard to type.
>>
>
> 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?

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

Sunnan

unread,
Feb 24, 2005, 12:05:50 AM2/24/05
to
Bear wrote:
>
> The combination #\ is annoying and hard to type.

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.

Sunnan

unread,
Feb 24, 2005, 12:22:07 AM2/24/05
to
I wrote:
> That said, I'm not fundamentally opposed to seeing a lisp which uses the
> 'c' construct, possibly in conjunction with another syntax for (quote).

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

Marco Baringer

unread,
Feb 24, 2005, 6:39:17 AM2/24/05
to
Ray Dillinger <be...@sonic.net> writes:

> 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

Hans Oesterholt-Dijkema

unread,
Feb 24, 2005, 10:07:17 AM2/24/05
to
On Thu, 24 Feb 2005 04:08:44 +0000, Ray Dillinger wrote:

>
> 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 #\...

Alexander Schmolck

unread,
Feb 24, 2005, 11:08:13 AM2/24/05
to
Ray Dillinger <be...@sonic.net> writes:

> 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

Christophe Rhodes

unread,
Feb 24, 2005, 11:14:42 AM2/24/05
to
Ray Dillinger <be...@sonic.net> writes:

> 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

Pascal Bourguignon

unread,
Feb 24, 2005, 12:12:10 PM2/24/05
to
Ray Dillinger <be...@sonic.net> writes:

> 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.

Bruce Lewis

unread,
Feb 24, 2005, 12:50:55 PM2/24/05
to
Ray Dillinger <be...@sonic.net> writes:

> 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.

Harald Hanche-Olsen

unread,
Feb 24, 2005, 3:43:23 PM2/24/05
to
+ Pascal Bourguignon <sp...@mouse-potato.com>:

| 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

Ulrich Hobelmann

unread,
Feb 24, 2005, 4:02:34 PM2/24/05
to
Ray Dillinger wrote:
>
> The combination #\ is annoying and hard to type.

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.

Edi Weitz

unread,
Feb 24, 2005, 4:23:21 PM2/24/05
to
On Thu, 24 Feb 2005 15:02:34 -0600, Ulrich Hobelmann <u.hob...@web.de> wrote:

> 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")

Taylor Campbell

unread,
Feb 24, 2005, 6:33:15 PM2/24/05
to
I really don't see what's wrong with a change in shifting -- and I'd
hate to use single-quotes to delimit characters, first because of all
of the code that would be horribly broken, second because QUOTE would
no longer have a meaningful mnemonic, and third because the single-
quote key is so close to the return key, which always bites me --;
however, there is one thing I'd like to change in the character syntax:
the named versus literal characters. I think it would make much more
sense to have two different octothorpe dispatch characters for a
character syntax: one for exact or literal characters & one for named
characters. Maclisp did this, if I recall correctly: #/x read as the
literal character x, while #\FOO read as the character named FOO, such
as #\NEWLINE or #\SPACE. I think this would be a useful convention to
adopt, and it wouldn't have to horribly break every bit of code ever
written in Scheme that uses character literals. (Existing readers
would just need to add #/ as a literal character syntax and leave the
reader for #\x unchanged.)

Coby Beck

unread,
Feb 24, 2005, 9:57:23 PM2/24/05
to
"Bruce Lewis" <brl...@yahoo.com> wrote in message
news:nm9fyzl...@biohazard-cafe.mit.edu...

> Ray Dillinger <be...@sonic.net> writes:
>
>> 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.

what about backspace, return, tab etc?

--
Coby Beck
(remove #\Space "coby 101 @ big pond . com")


Bruce Lewis

unread,
Feb 25, 2005, 9:35:55 AM2/25/05
to
"Coby Beck" <cb...@mercury.bc.ca> writes:

> "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.

Ray Dillinger

unread,
Mar 11, 2005, 9:33:53 PM3/11/05
to

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

lin8080

unread,
Mar 12, 2005, 8:10:09 AM3/12/05
to

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

unread,
Mar 13, 2005, 10:55:02 AM3/13/05
to
lin8080 wrote:

> 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

0 new messages