tags:

views:

59

answers:

2

When using parenscript if I execute

(parenscript:ps 
 (slot-value ($ "#mytextarea") 'selectionStart))

It produces the javascript

$('#mytextarea').selectionstart;

Note that selectionStart is now selectionstart. It lost the uppercase S on the Start! How do I keep that uppercase S around?

+6  A: 

Parenscript will automatically convert from the lisp naming convention (dashes separating words) to CamelCase, so:

(parenscript:ps 
 (slot-value ($ "#mytextarea") 'selection-start))

results in

"$('#mytextarea').selectionStart;"
Ramarren
If you need an initial capital letter in your symbol, you'll need to prefix the name with an asterisk.
HD
A: 

As Pillsy remarked, all symbols are upper-cased by default when they are read by the Lisp compiler. There is a way of turning that off, though. See the CLHS, 23.1.2 (Effect of Readtable Case on the Lisp Reader), and the description of the accessor readtable-case for details. As an example, you can enable the “invert” mode (which is arguably the only practical setting that is also case-sensitive) by putting the following into your Lisp source file:

#.(setf (readtable-case *readtable*) :invert)

Unfortunately, ParenScript does not seem to make much use of a custom readtable-case setting, even though it could (and, in my opinion, should) do so.

Matthias Benkard
How would you say Parenscript can make the best use of readtable-case? The Parenscript compiler gets code as s-expressions with symbols, so it doesn't know how the symbol names were read in. There's now a compile-file function where you can customize the reader, but that won't work for all PS code.
vsedach
@vsedach That's true. Still, in my opinion it's pretty clear what to do with mixed-case symbols (just leave them as they are), so the only issue left is what to do about all-uppercase and all-lowercase symbols. Personally, I'd suggest either assuming :INVERT by default or simply down-casing all such symbols (for backwards-compatibility) and making it a setting just as READTABLE-CASE is.
Matthias Benkard