Jim
Jim

Reputation: 329

Why are parenscript functions changed to all lowercase?

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?

Upvotes: 7

Views: 486

Answers (2)

Matthias Benkard
Matthias Benkard

Reputation: 15759

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.

Upvotes: 1

Ramarren
Ramarren

Reputation: 2520

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

Upvotes: 6

Related Questions