[Cuis] assignment operator questions
Juan Vuletich
juan at jvuletich.org
Wed May 23 20:41:29 CDT 2012
Hi Daniel,
Daniel Lyons wrote:
> Thought I should ask since I don't think an official position has been
> taken, and now seems like a better time to ask than after having
> written a bunch of code.
>
> In Cuis, _ is translated into ←, a left arrow, and this works as well
> for assignments as :=. Similarly, ^ is translated into ↑, an up
> arrow. I believe these behaviors originate in Smalltalk-80 and come to
> Cuis via Squeak.
>
Right.
> Pharo took the position that the underscore would be deprecated for
> assignment, and typing it in a Pharo image produces an underscore
> rather than a left arrow, and you must use := for assignment.
> Similarly, the caret produces a caret, though it works for
> returning values.
>
> My questions:
>
> - Is Cuis taking a position on this issue?
>
Sort of. The position Cuis takes is that's your choice.
Simply evaluating 'StrikeFont useUnderscore'displays the ASCII ^ and _
glyphs. If you ever want to go back to left and up arrow, evaluate
'StrikeFont useLeftArrow'. I included both sets of glyphs so everybody
can choose.
Please note that this doesn't affect the parser. In any case both _ and
:= are valid for assignment, but not for use in selectors or variable
names. Preferences #allowUnderscoreSelectors and
#allowUnderscoreAssignments give you some control over this. If you set
#allowUnderscoreSelectors to true and #allowUnderscoreAssignments to
false, you get the standard behavior in many Smalltalks, where the
underscore can be part of selectors or variable names. In this case, if
you modify existing methods, you need to change assignments to be := so
they will compile.
If you set both preferences to true, you can use both, but assignment
needs a space before and after, to disambiguate.
> - Is Pharo compatibility affected by allowing this? Is that something
> we are concerned about?
>
If you want maximum compatibility for your code, use always := for
assignment, and don't use left arrow or underscore for anything at all.
Then, the above mentioned preferences are irrelevant.
> - Is it worth considering actual translation of these characters into
> their Unicode equivalents and enabling those instead? This raises
> other questions about Unicode compatibility as well.
>
Well, Cuis doesn't include Unicode support. I think Unicode should be
considered an optional package, for those applications that need it. The
Smalltalk environment itself doesn't need it. It is not worth to add
Unicode just for the left and up arrow.
> Thanks
Cheers,
Juan Vuletich
More information about the Cuis
mailing list