walrus with a twist :+= or ...

Avi Gross avigross at verizon.net
Wed Oct 27 22:15:09 EDT 2021


My apologies, again. I got Chris going and although quite humorous, we may
want to allow a slew of emoticons!

But a serious question is now that we sort of have UNICODE, and even many
editors and other programs support it, perhaps it might make sense for some
operations in computer languages to make use of them. Some languages might
replace something like <- with an arrow symbol and those with special
symbols like Inf might use the infinity symbol instead. More importantly,
adding new operators might get easier. Some existing languages like APL used
overstrikes to create some symbols. Some languages have a built-in extension
method such as R that allows you to create arbitrary functions by placing
them between % signs as in %>% or %percentile% 

If Python wanted to add more flexibility than admittedly it already has,
then possibly something like I jokingly suggested as a walrus version of :=
might be doable by just defining some new function bound to a symbol which,
when run, is told of the operands on either side. 

But dreaming aside, from an academician and programmer as well as a lazy bum
side of me, it is often perhaps easiest to design a new language practically
from scratch with ideas that it completely follow the paradigms you want.
SCALA is an example among others. Both a strength and weakness in Python as
it has grown is that it does so many things in so many ways as more and more
is grafted on. The relatively few existing symbols are overloaded too much
so it takes some context to figure out when a : or parenthesis or even %
sign means one of multiple things. The recent discussion sort of highlighted
how a comma meaning multiple things may be confusing. if we extend a
feature. 

One reasonable design might be to expand the allowed symbols and use them as
needed. A colon might be used only one way. If you need a :: operator, it
can be a single token and a single character, perhaps clearly having the two
parts closer together or one part slightly raised or lowered. A += and >=
operator may again be the one symbol version so that + and = always mean the
same thing.

But it is a tad too late to make an existing language or users on existing
keyboards, do this. A language course I am using makes compromises so using
a partial pop-up keyboard lets me select characters with special twists like
an umlaut rather than showing a plain U or perhaps a :U instead of Ü or
allowing an SS to be typed instead of ß. When used on character-only
scenarios, obviously you let the users mis-spell these ways but that is not
an ideal way to learn a language or write in it.

-----Original Message-----
From: Python-list <python-list-bounces+avigross=verizon.net at python.org> On
Behalf Of Chris Angelico
Sent: Wednesday, October 27, 2021 9:11 PM
To: Python <python-list at python.org>
Subject: Re: walrus with a twist :+= or ...

On Thu, Oct 28, 2021 at 11:58 AM Avi Gross via Python-list
<python-list at python.org> wrote:
> On a serious note, if it was ever considered a good idea, what would 
> be an acceptable sequence of symbols that might not break or confuse 
> existing programs and what would we call it? I mean what animal, of
course.
>
>
>
> What do these look like in some fonts? :+=   :-=   :*=   :/=   :%=
>

What we need is a few more generic operators that can be put together
appropriately. For instance, when you need a copy of a list, you can use the
"robot face" operator:

stuff[:]

Perhaps we need some more slice variants. We can already grin:

stuff[
    :D
]

and stick out our tongues:

stuff[
    :P
]

and even gasp in surprise:

stuff[
    :O
]

but the language has an emotional bias towards sadness:

stuff[
    :(
)]

since there's no corresponding happiness emoji, nor even ambivalence:

stuff[
    :|
]

However, a wry smile is permitted.

stuff[
    :\
]

The lack of language support for such a fundamental emotion as happiness is
a major flaw and needs to be corrected ASAP.

ChrisA
--
https://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list