display _ as left arrow (was Re: Help on sending a UDP Packet)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

display _ as left arrow (was Re: Help on sending a UDP Packet)

Stefan Monnier
> The idea of GNU Smalltalk is to use a UNIX command-line style environment,
> and use "Emacs" (editor) and so on ... it's not about emulating the more graphically oriented
> development environment of older Smalltalk implementations.
>
> So by default it is logical that GNU smalltalk limits itself to strict ASCII characters.
>
> Using '_' is just fine as it currently is :
>
> https://www.gnu.org/software/smalltalk/manual/html_node/Syntax.html
>
> in the footnote it describes '_'.

BTW.  Currently `smalltalk-mode` in Emacs can display the `^` and the
`:=` operators as up/left arrows if you activate the `prettify-symbols-mode`.
It'd be trivial to add `_` to that with the patch below.

The downside is that then both `_` and `:=` would be displayed in the
same way.  And since GNU Smalltalk seems to encourage the use of `:=`
over `_`, maybe it's better to keep `_` ugly?


        Stefan


diff --git a/smalltalk-mode.el b/smalltalk-mode.el
index f662fe1d69..768396b71b 100644
--- a/smalltalk-mode.el
+++ b/smalltalk-mode.el
@@ -534,6 +534,7 @@ of the line where the search succeeded.  Otherwise, return nil."
 
 (defvar smalltalk-prettify-symbols-alist
   '(("^" . ?↑)
+    ("_" . ?←)
     (":=" . ?←)))
 
 ;;;; ---[ Interactive functions ]---------------------------------------


Reply | Threaded
Open this post in threaded view
|

Re: display _ as left arrow (was Re: Help on sending a UDP Packet)

stes

It would be a good idea to have the modification below in the gnu smalltalk git repository;
it's coherent with the comments on _ and := in the GNU smalltalk manual,
that those are both accepted by gnu smalltalk as assignment.

By the way, comments are enclosed in double quotes "" but what I observe with the Alto Smalltalk-72 font,
is that those are printed as 'fingers' symbols, but I doubt that is current practice.

Also the ! character is printed as a doubled up-arrow.

----- Op 11 jan 2021 om 17:28 schreef Stefan Monnier [hidden email]:

>
> diff --git a/smalltalk-mode.el b/smalltalk-mode.el
> index f662fe1d69..768396b71b 100644
> --- a/smalltalk-mode.el
> +++ b/smalltalk-mode.el
> @@ -534,6 +534,7 @@ of the line where the search succeeded.  Otherwise, return
> nil."
>
> (defvar smalltalk-prettify-symbols-alist
>   '(("^" . ?↑)
> +    ("_" . ?←)
>     (":=" . ?←)))
>
>  ;;;; ---[ Interactive functions ]---------------------------------------

Reply | Threaded
Open this post in threaded view
|

Re: display _ as left arrow (was Re: Help on sending a UDP Packet)

Stefan Monnier
> It would be a good idea to have the modification below in the gnu smalltalk git repository;
> it's coherent with the comments on _ and := in the GNU smalltalk manual,
> that those are both accepted by gnu smalltalk as assignment.

I don't have access to the Smalltalk Git, but if there's a consensus
that displaying `_` as a left arrow just like `:=` is a better choice,
I'll be happy to change it in the GNU ELPA package
(http://elpa.gnu.org/packages/smalltalk-mode.html)

> By the way, comments are enclosed in double quotes "" but what I observe
> with the Alto Smalltalk-72 font,
> is that those are printed as 'fingers' symbols, but I doubt that is current practice.

Also I'm not sure it'd be helpful: the purpose of displaying `_` and
`:=` as an arrow is that it's meant to express the semantics in a more
intuitive way, whereas I don't know that "fingers" would express the
notion of comment more intuitively (also I'm not sure which Unicode char
would be used for that, but a quick look here with `C-x 8 RET` didn't
turn up anything covered by my currently installed fonts).
Nowadays coloring is more traditionally used to indicate that something
is a comment.

> Also the ! character is printed as a doubled up-arrow.

Similarly here, I don't see why a doubled up-arrow (I guess `⇑` ?)
would convey the semantics in a more intuitive manner than a `!`.
So I'm not sure it'd be worth the trouble.


        Stefan


Reply | Threaded
Open this post in threaded view
|

Re: display _ as left arrow (was Re: Help on sending a UDP Packet)

stes


----- Op 11 jan 2021 om 18:29 schreef Stefan Monnier [hidden email]:
>
> Similarly here, I don't see why a doubled up-arrow (I guess `⇑` ?)
> would convey the semantics in a more intuitive manner than a `!`.

The doubled up-arrow that I meant is in the screenshot in attach.

I am not sure however whether the Alto Serif Smalltalk-72 font,
is a faithful reproduction of how old Xerox systems/old terminals looked like ...

alto-modp-inverse.png (59K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: display _ as left arrow (was Re: Help on sending a UDP Packet)

stes

The hand with pointing finger that is used for comments,
is better visibile in the attached screenshot "vi-with-alto-arrows.png".

See screenshot for a better picture of those 'finger' and 'doubled up-arrow' symbols.

My guess is that those creative symbols are inventions of the font designer,
who designed the Alto Serif Smalltalk-72 font.

I don't think they relate to actual old Xerox Smalltalk systems,
but it could be, I don't know.

For the left-arrow (_) and up-arrow (^) this is on the other hand well documented.

David Stes

vi-with-alto-arrows.png (74K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: display _ as left arrow (was Re: Help on sending a UDP Packet)

Gnu mailing list
In reply to this post by Stefan Monnier

Stefan Monnier writes:

>
> The downside is that then both `_` and `:=` would be displayed in the
> same way.  And since GNU Smalltalk seems to encourage the use of `:=`
> over `_`, maybe it's better to keep `_` ugly?
>
>
>         Stefan
>
>
> diff --git a/smalltalk-mode.el b/smalltalk-mode.el
> index f662fe1d69..768396b71b 100644
> --- a/smalltalk-mode.el
> +++ b/smalltalk-mode.el
> @@ -534,6 +534,7 @@ of the line where the search succeeded.  Otherwise, return nil."
>  
>  (defvar smalltalk-prettify-symbols-alist
>    '(("^" . ?↑)
> +    ("_" . ?←)
>      (":=" . ?←)))
>  
>  ;;;; ---[ Interactive functions ]---------------------------------------

I tried that, and it is not as nice as one would think. It is not
highlighted as an operator for one.

Smalltalk does not allow a leading underscore for variable names because
of this usage of underscore. In many other languages there is a
convention of using leading underscore to mean something, like to
supress warning of unused variables. Many people including me like the
visual cue it provides.

Derek


Reply | Threaded
Open this post in threaded view
|

Re: display _ as left arrow (was Re: Help on sending a UDP Packet)

stes

----- Op 12 jan 2021 om 20:15 schreef help-smalltalk [hidden email]:

> I tried that, and it is not as nice as one would think. It is not
> highlighted as an operator for one.

OK.  But you mean emacs is not seeing _ as operator, if I understand correctly.

GNU smalltalk supports _ as operator, and it works fine.
 
> Smalltalk does not allow a leading underscore for variable names because
> of this usage of underscore. In many other languages there is a
> convention of using leading underscore to mean something, like to
> supress warning of unused variables. Many people including me like the
> visual cue it provides.

Except when you switch to a font that uses a "legacy" encoding,
where _ is displayed as a left arrow.  In that case, those variables,
with underscores in them, look weird.

They look weird because they contain left arrows.

My understanding is also that the GNU smalltalk manual also warns against
using _ in variable names as it may lead to portability problems.

> Derek

Reply | Threaded
Open this post in threaded view
|

Re: display _ as left arrow (was Re: Help on sending a UDP Packet)

Gnu mailing list

[hidden email] writes:

> ----- Op 12 jan 2021 om 20:15 schreef help-smalltalk [hidden email]:
>
>> I tried that, and it is not as nice as one would think. It is not
>> highlighted as an operator for one.
>
> OK.  But you mean emacs is not seeing _ as operator, if I understand correctly.
>
You quoted me out of context. I was commenting on the patch and what I
mean was the patch you made does not do the right thing, that's all. To
do the right thing, ie, with prettified symbol and syntax highlight, you
need to do more; patch welcomed.

Derek


Reply | Threaded
Open this post in threaded view
|

Re: display _ as left arrow (was Re: Help on sending a UDP Packet)

stes

Sorry but I didn't write or submit the patch.  I think Stefan Monnier wrote it.

Initially I liked the idea of a pretty-print filter,
but I'm not so sure any longer.

It may complicate things;  perhaps it's not such a good idea to have a pretty-print filter,
anyway.

Most of all I don't mind using ^ and _ simple symbols,
they are just symbols, so if they mean "return a value" and "assign a value",
that's fine.

This is defined by the Blue Book Smalltalk language definition,
as there's no doubt about it that the Blue Book Smalltalk language definition,
defines variable assignment by the "left arrow".

The Smalltalk language definition Blue Book does not define ":=" as far as I know.

David Stes

----- Op 12 jan 2021 om 21:05 schreef help-smalltalk [hidden email]:

> [hidden email] writes:
>
>> ----- Op 12 jan 2021 om 20:15 schreef help-smalltalk [hidden email]:
>>
>>> I tried that, and it is not as nice as one would think. It is not
>>> highlighted as an operator for one.
>>
>> OK.  But you mean emacs is not seeing _ as operator, if I understand correctly.
>>
> You quoted me out of context. I was commenting on the patch and what I
> mean was the patch you made does not do the right thing, that's all. To
> do the right thing, ie, with prettified symbol and syntax highlight, you
> need to do more; patch welcomed.
>
> Derek

Reply | Threaded
Open this post in threaded view
|

Re: display _ as left arrow (was Re: Help on sending a UDP Packet)

Gnu mailing list

[hidden email] writes:

>
> The Smalltalk language definition Blue Book does not define ":=" as far as I know.
>
To be fair, nor does it define "_" or "^". All it says was "left arrow" or
"uparrow". We got to make do with what we have.

Derek


Reply | Threaded
Open this post in threaded view
|

Re: display _ as left arrow (was Re: Help on sending a UDP Packet)

stes

Hi Derek,

----- Op 12 jan 2021 om 22:08 schreef help-smalltalk [hidden email]:

>> The Smalltalk language definition Blue Book does not define ":=" as far as I
>> know.
>>
> To be fair, nor does it define "_" or "^". All it says was "left arrow" or
> "uparrow". We got to make do with what we have.
>
> Derek

Yes you're right.

Also it was wrong from my side to ask to update the 'pretty-print' filter.

If the pretty-print filter works fine for the moment,
by displaying := as a left-arrow, then that's a good solution,
to use := and at the same time use Smalltalk style left-arrows for assignments.

So I don't really ask for an update of the pretty-print filter,
but if somebody would implement it, then that's also fine of course.

As you wrote, you're open to a patch if somebody would develop it,
but it would perhaps be non-trivial to do it.

Because I'm happy with simply _ (underscore) and I use a font that displays
the underscore as a left-arrow , there's no problem.

Note that there are several fonts around on the internet
that display a left-arrow at the position that the current underscore is.

Smalltalk is a relatively "old" language.

What I like about GNU Smalltalk is that it tries to run Smalltalk in UNIX,
while still retaining compatibility with the blue book.

If I understand correctly the origins of Smalltalk are NOT on UNIX.

But GNU Smalltalk certainly is a UNIX-oriented implementation, as far as I can see.


Regards,
David Stes

Reply | Threaded
Open this post in threaded view
|

Re: display _ as left arrow (was Re: Help on sending a UDP Packet)

Stefan Monnier
In reply to this post by Stefan Monnier
Derek Zhou writes:
> Accept, but not encourage. None of the GNU smalltak and Squeak's official
> example code use it. ":=" at least is a cognate from Pascal, what else is
> using "_" ?

Indeed, and that's a good reason to say that it doesn't matter very much
if `smalltalk-mode` prettifies `_` or not, but it still doesn't seem to hurt.

Derek Zhou writes:
> You quoted me out of context. I was commenting on the patch and what I
> mean was the patch you made does not do the right thing, that's all. To
> do the right thing, ie, with prettified symbol and syntax highlight, you
> need to do more; patch welcomed.

Ah, you mean that `smalltalk-mode` doesn't handle `_` correctly w.r.t
indentation, for example?  Indeed, a I think a patch is in order
for that.

I installed the patch below for now.  It includes the change to display
`_` as a left-arrow, since it seems noone strongly objected to it and it
can be helpful in pointing out the difference between `a_-1` and `a
_-1`.
Also it bumps the version number so as to finally release a new GNU ELPA
package for it.

> Initially I liked the idea of a pretty-print filter,
> but I'm not so sure any longer.
>
> It may complicate things;  perhaps it's not such a good idea to have a pretty-print filter,
> anyway.

`smalltalk-prettify-symbols-alist` is just a set of rules to change
the display (and only the display) of those symbols mentioned.
The prettification is only applied when the users activate
`prettify-symbols-mode`, which is not enabled by default (because
indeed, it's not always a good idea).


        Stefan




Reply | Threaded
Open this post in threaded view
|

Re: display _ as left arrow (was Re: Help on sending a UDP Packet)

Stefan Monnier
> I installed the patch below for now.

Duh, here it is,


        Stefan


diff --git a/smalltalk-mode.el b/smalltalk-mode.el
index f662fe1d69..5260b1e510 100644
--- a/smalltalk-mode.el
+++ b/smalltalk-mode.el
@@ -2,8 +2,8 @@
 
 ;; Author: Steve Byrne
 ;; Maintainer: Derek Zhou <[hidden email]>
-;; Version: 3.2.92
-;; Copyright 1988-2020  Free Software Foundation, Inc.
+;; Version: 4.0
+;; Copyright 1988-2021  Free Software Foundation, Inc.
 
 ;; This file is part of GNU Smalltalk.
 
@@ -39,6 +39,13 @@
 ;; Incorporates Frank Caggiano's changes for Emacs 19.
 ;; Updates and changes for Emacs 20 and 21 by David Forster
 
+;;; News
+
+;; New in 4.0:
+;; - Completely rewritten indentation code, which now relies on SMIE
+;; - Support for `prettify-symbols-mode'
+;; - Use `electric-indent-mode'
+
 ;;; Code:
 
 (require 'smie nil t)                   ;Not indispensable (yet).
@@ -352,10 +359,11 @@ of the line where the search succeeded.  Otherwise, return nil."
              ("<" id ">")              ;Meta info like `comment' and `category'
              (exp "!" exp)             ;GNU Smalltalk extension
              (id ":=" exp)             ;Assignment
+             (id "_" exp)             ;Assignment
              (exp ";" exp)             ;Message cascading
              (exp "\n" exp)            ;Separator for bang method header
              (exp "." exp)))           ;Separate instructions
-      '((assoc "!") (assoc "|") (assoc "." "\n") (noassoc ":=" "^")
+      '((assoc "!") (assoc "|") (assoc "." "\n") (noassoc ":=" "_" "^")
         (assoc ";") (assoc "kw-sel" "bin-sel"))))))
 
 (defconst smalltalk--smie-id-re
@@ -453,7 +461,7 @@ of the line where the search succeeded.  Otherwise, return nil."
   "Return non-nil if the thing at point is allowed to be an /expr/."
   (save-excursion
     (pcase (smalltalk--smie-backward-token)
-      ((or `"bin-sel" `"kw-sel" ":=" `"." `"^" `"!" "|")
+      ((or `"bin-sel" `"kw-sel" ":=" "_" `"." `"^" `"!" "|")
        t)
       ((or `"|-open" `";" `"lit-symbol" "lit-number") nil)
       ;;`""' means we bumped into a paren or a string.
@@ -475,7 +483,7 @@ of the line where the search succeeded.  Otherwise, return nil."
     (`(:elem . basic) smalltalk-indent-amount)
     (`(:after . "|") 0)
     (`(:after . ">") 0)                 ;Indentation after a pragma.
-    (`(:after . ":=") smalltalk-indent-amount)
+    (`(:after . ,(or ":=" "_")) smalltalk-indent-amount)
     (`(:after . "\n") (if (smie-rule-parent-p "!") ;GST2 method header separator
                           smalltalk-indent-amount))
     (`(:after . ";")
@@ -534,6 +542,7 @@ of the line where the search succeeded.  Otherwise, return nil."
 
 (defvar smalltalk-prettify-symbols-alist
   '(("^" . ?↑)
+    ("_" . ?←)
     (":=" . ?←)))
 
 ;;;; ---[ Interactive functions ]---------------------------------------