From: goose
Subject: case-insens-tive symbols
Date: 
Message-ID: <dsljh3$6il$1@ctb-nnrp2.saix.net>
Hello all

How do I setup clisp to not convert all my symbols to uppercase?
I want the case to be maintained.

tia
goose

From: Harald Hanche-Olsen
Subject: Re: case-insens-tive symbols
Date: 
Message-ID: <pco64nly21x.fsf@shuttle.math.ntnu.no>
+ goose <·····@webmail.co.za>:

| How do I setup clisp to not convert all my symbols to uppercase?
| I want the case to be maintained.

(setf (readtable-case *readtable*) :preserve)

This is the same in all common lisps.  Note that now you have to write
all symbols from the COMMON-LISP pacage in capitals.  Personally, I
much prefer :invert rather than :upcase, and then typing (almost) all
symbols as lowercase.  This will have the nice side effect of printing
uppercase symbols in lower case.  Well, I think it's nice anyway, and
many (but not all) others seem to agree.  I suspect this is what you
really want too.

(Isn't it wonderful, having people tell you what you really want?)

-- 
* Harald Hanche-Olsen     <URL:http://www.math.ntnu.no/~hanche/>
- It is undesirable to believe a proposition
  when there is no ground whatsoever for supposing it is true.
  -- Bertrand Russell
From: goose
Subject: Re: case-insens-tive symbols
Date: 
Message-ID: <dslp73$k8k$1@ctb-nnrp2.saix.net>
First, thanks for the prompt response.

Harald Hanche-Olsen wrote:
> + goose <·····@webmail.co.za>:
> 
> | How do I setup clisp to not convert all my symbols to uppercase?
> | I want the case to be maintained.
> 
> (setf (readtable-case *readtable*) :preserve)
> 
> This is the same in all common lisps.  Note that now you have to write
> all symbols from the COMMON-LISP pacage in capitals.  

Damn :-(

> Personally, I
> much prefer :invert rather than :upcase, and then typing (almost) all
> symbols as lowercase.  This will have the nice side effect of printing
> uppercase symbols in lower case.  Well, I think it's nice anyway, and
> many (but not all) others seem to agree.  I suspect this is what you
> really want too.

not really, no. What I am doing is writing a macro to generate
classes which are used to communicate with a tcl/tk app (wish).

wish will not recognise "ENTRY" but will happily parse
"entry" properly. Since my functions which do the actual
communications use the macro-generated classes, I need to preserve
the case when I call the macro and use the class like so:

    (make-widget-class 'entry)
    ...
    (defparameter *name-line* (make-instance 'entry))

sadly, that (eventually) goes to wish like this:

    ENTRY .name_line

instead of

    entry .name_line



> 
> (Isn't it wonderful, having people tell you what you really want?)
> 

Maybe, but you really don't have to - I've already got a wife to
do that :-)

thanks
goose
From: Peter Seibel
Subject: Re: case-insens-tive symbols
Date: 
Message-ID: <m2d5ht5w80.fsf@gigamonkeys.com>
goose <·····@webmail.co.za> writes:

> First, thanks for the prompt response.
>
> Harald Hanche-Olsen wrote:
>> + goose <·····@webmail.co.za>:
>> | How do I setup clisp to not convert all my symbols to uppercase?
>> | I want the case to be maintained.
>> (setf (readtable-case *readtable*) :preserve)
>> This is the same in all common lisps.  Note that now you have to
>> write
>> all symbols from the COMMON-LISP pacage in capitals.  
>
> Damn :-(
>
>> Personally, I much prefer :invert rather than :upcase, and then
>> typing (almost) all symbols as lowercase. This will have the nice
>> side effect of printing uppercase symbols in lower case. Well, I
>> think it's nice anyway, and many (but not all) others seem to
>> agree. I suspect this is what you really want too.
>
> not really, no. What I am doing is writing a macro to generate
> classes which are used to communicate with a tcl/tk app (wish).
>
> wish will not recognise "ENTRY" but will happily parse "entry"
> properly. Since my functions which do the actual communications use
> the macro-generated classes, I need to preserve the case when I call
> the macro and use the class like so:
>
>     (make-widget-class 'entry)
>     ...
>     (defparameter *name-line* (make-instance 'entry))
>
> sadly, that (eventually) goes to wish like this:
>
>     ENTRY .name_line
>
> instead of
>
>     entry .name_line

So short of globally changing how the reader reads symbols you can
either selectively control how certain symbols are read:

  (define-with-thing |entry| ...)

where the ||'s are escapes that prevent the reader from smashing case
so the putative DEFINE-WITH-THING macro will actually see a symbol
named "entry" rather than "ENTRY". Or, if you always want to use
lowercase names you can deal with that in the macro:

  (defmacro define-wish-thing (name ...)
    (let ((name-for-wish (string-downcase name)))
      `(... (send-wish-command ,name-for-wish ...))))

-Peter

-- 
Peter Seibel           * ·····@gigamonkeys.com
Gigamonkeys Consulting * http://www.gigamonkeys.com/
Practical Common Lisp  * http://www.gigamonkeys.com/book/
From: goose
Subject: Re: case-insens-tive symbols
Date: 
Message-ID: <dso3tv$ngp$1@ctb-nnrp2.saix.net>
Peter Seibel wrote:
> goose <·····@webmail.co.za> writes:

<snipped>

>>not really, no. What I am doing is writing a macro to generate
>>classes which are used to communicate with a tcl/tk app (wish).
>>
>>wish will not recognise "ENTRY" but will happily parse "entry"
>>properly. Since my functions which do the actual communications use
>>the macro-generated classes, I need to preserve the case when I call
>>the macro and use the class like so:
>>
>>    (make-widget-class 'entry)
>>    ...
>>    (defparameter *name-line* (make-instance 'entry))
>>
>>sadly, that (eventually) goes to wish like this:
>>
>>    ENTRY .name_line
>>
>>instead of
>>
>>    entry .name_line
> 
> 
> So short of globally changing how the reader reads symbols you can
> either selectively control how certain symbols are read:
> 
>   (define-with-thing |entry| ...)
> 
> where the ||'s are escapes that prevent the reader from smashing case
> so the putative DEFINE-WITH-THING macro will actually see a symbol
> named "entry" rather than "ENTRY". Or, if you always want to use
> lowercase names you can deal with that in the macro:
> 
>   (defmacro define-wish-thing (name ...)
>     (let ((name-for-wish (string-downcase name)))
>       `(... (send-wish-command ,name-for-wish ...))))
> 

Thanks, what I really needed was the strign-downcase function :-)

Everything is fine in uppercase, only wish doesn't like it, so
now the function that prints out the class to wish uses string-downcase
on the slot that holds the classes name.

regards
goose
From: Alexander Schmolck
Subject: Re: case-insens-tive symbols
Date: 
Message-ID: <yfslkwhwkgb.fsf@oc.ex.ac.uk>
goose <·····@webmail.co.za> writes:

> > Personally, I
> > much prefer :invert rather than :upcase, and then typing (almost) all
> > symbols as lowercase.  This will have the nice side effect of printing
> > uppercase symbols in lower case.  Well, I think it's nice anyway, and
> > many (but not all) others seem to agree.  I suspect this is what you
> > really want too.
> 
> not really, no. 

Oh yes you do. You just don't know it yet.

> What I am doing is writing a macro to generate classes which are used to
> communicate with a tcl/tk app (wish). wish will not recognise "ENTRY" but
> will happily parse "entry" properly. Since my functions which do the actual
> communications use the macro-generated classes, I need to preserve the case
> when I call the macro and use the class like so:

Why do you think you need to preserve the case? Since case-inversion ought to
be bijective, it should do just as fine. All you need to do is case-invert
from and to tcl/tk. I fail to see why this should pose a problem. It might
seem a slighly bizarre way to go about things, but due to the historical
situation that allmost all symbols in common lisp programs are upercase
(including everything in the CL package), it's almost certainly your best bet.

> 
>     (make-widget-class 'entry)
>     ...
>     (defparameter *name-line* (make-instance 'entry))
> 
> sadly, that (eventually) goes to wish like this:
> 
>     ENTRY .name_line
> 
> instead of
> 
>     entry .name_line
> 
> 
> 
> > (Isn't it wonderful, having people tell you what you really want?)
> 
> >
> 
> 
> Maybe, but you really don't have to - I've already got a wife to
> do that :-)

Well, now you've got 3 people telling you what you really want (what's your
wife's opinion on this matter?).
 
> thanks
> goose

'as
From: Alexander Schmolck
Subject: Re: case-insens-tive symbols
Date: 
Message-ID: <yfshd75wjed.fsf@oc.ex.ac.uk>
Alexander Schmolck <··········@gmail.com> writes:

> All you need to do is case-invert from and to tcl/tk. 

To be a bit more clear, I think you only need to take care of the cases where
you convert a symbol to a string and vice versa "by hand", rather than using
read/write. Here is some dodgy code to convert strings to symbols trying to
and vice versa, trying to divine what case conversion you *really* want (of
course, if you insist, you can also specify what you *think* you want).

  (defvar *default-case-conversion* nil)
  (defsubst char-swapcase (c)
    (declare (type character c) (optimize (speed 3)))
    (cond ((upper-case-p c)
           (char-downcase c))
          (t (char-upcase c))))
  (defun %case-convert (case-conversion name)
    (when (eq t case-conversion)
    (setq case-conversion (or *default-case-conversion*
                              (case (readtable-case *readtable*)
                                ((:upcase :invert) :invert)
                                (t :preserve)))))
    (ecase case-conversion 
        (:invert (map 'string #'char-swapcase name))
        (:upcase (string-upcase name))
        (:downcase (string-downcase name))
        ((nil :preserve) name)
        ))
  (defun symbol->string (symbol &optional (qualified-p nil)
                         (case-conversion t))
    (%case-convert case-conversion
     (if qualified-p
         (concatenate 'string
                      (package-name (symbol-package symbol))
                      (if (symbol-external-p symbol) ":" "::")
                      (symbol-name symbol))
         (copy-seq (symbol-name symbol)))))
  (defun string->symbol (string &optional package (case-conversion t))
    (apply #'intern (%case-convert case-conversion string) package))

'as
From: goose
Subject: Re: case-insens-tive symbols
Date: 
Message-ID: <dso4en$op8$1@ctb-nnrp2.saix.net>
Alexander Schmolck wrote:
> goose <·····@webmail.co.za> writes:

<snipped>

> Why do you think you need to preserve the case? Since case-inversion ought to
> be bijective, it should do just as fine. All you need to do is case-invert
> from and to tcl/tk. I fail to see why this should pose a problem. 

The tcl/tk symbols which are meant to be lowercase have to be lowercase,
and the ones (if any) that are meant to be uppercase have to be
uppercase. Preserving case isn't (as I replied to Peter above) what
was needed in any case (hehe), nor was the case-inversion solution.

The "forcing to downcase of certain slots only" is what I had needed.

I would gladly post my (incomplete) code here for criticism and
suggestion, but it is rather long (about 200 lines) for the entire
file. It's basicly a wrapper around wish (on linux for now, others
later) for my clisp programs to have some sort of gui interface.

*to entire group*
Is anyone vaguely interested in a(n incomplete) tcl/tk gui for clisp?

<snipped>

>>>(Isn't it wonderful, having people tell you what you really want?)
>>
>>
>>Maybe, but you really don't have to - I've already got a wife to
>>do that :-)
> 
> 
> Well, now you've got 3 people telling you what you really want (what's your
> wife's opinion on this matter?).
>  

IIRC, it was "stop playing with the computer and come to
bed already" :-)

thanks again
goose
From: Peter Seibel
Subject: Re: case-insens-tive symbols
Date: 
Message-ID: <m2ek264p9d.fsf@gigamonkeys.com>
goose <·····@webmail.co.za> writes:

> *to entire group*
> Is anyone vaguely interested in a(n incomplete) tcl/tk gui for clisp?

Not to ruin your fun but you do know about Ltk[1], don't you?

-Peter

[1] <http://www.peter-herth.de/ltk/>

-- 
Peter Seibel           * ·····@gigamonkeys.com
Gigamonkeys Consulting * http://www.gigamonkeys.com/
Practical Common Lisp  * http://www.gigamonkeys.com/book/
From: Florian Weimer
Subject: Re: case-insens-tive symbols
Date: 
Message-ID: <878xsgkc5g.fsf@mid.deneb.enyo.de>
* goose:

> How do I setup clisp to not convert all my symbols to uppercase?

Try "clisp -modern".
From: Pascal Bourguignon
Subject: Re: case-insens-tive symbols
Date: 
Message-ID: <873bio34pa.fsf@thalassa.informatimago.com>
Florian Weimer <··@deneb.enyo.de> writes:

> * goose:
>
>> How do I setup clisp to not convert all my symbols to uppercase?
>
> Try "clisp -modern".

People using several libraries won't be able to use at the same time
-modern and -traditional to satisfy each library.
Libraries should not depend on implementation specific behavior like this.


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

CAUTION: The mass of this product contains the energy equivalent of
85 million tons of TNT per net ounce of weight.