Sujet : Re: Top 10 most common hard skills listed on resumes...
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.cDate : 11. Sep 2024, 16:15:09
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240911080107.74@kylheku.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2024-09-11, Bart <
bc@freeuk.com> wrote:
On 11/09/2024 01:22, Ben Bacarisse wrote:
Bart <bc@freeuk.com> writes:
And yes I'm still committed to that symmetry. I'ved used it for countless
language implementations. C is little different other than it has a
700-page standard that suggests a recommended model of how it's supposed to
work.
>
You can't really use that to bash me about the head with and maintain that
all my ideas about language implementation are wrong because C views
assignment in its own idiosyncratic manner.
I don't want to bash you about the head, but what C says about
assignment has /always/ been the point, and your implementation of C
will be wrong if you don't follow the rules about C's assignments. You
/know/ the LH and RH side of a C assignment have different constraints
(you have said so yourself) yet you persist in defending your original
claim that what is needed on the two sides "is exactly the same".
>
I've listed the aspects that I said are the same.
>
That is, if something is a legal LHS term, then its syntax, and its
type, are identical to that term appearing on the RHS.
But the converse isn't true. "a = b" is a valid RHS term, yet isn't
always valid on the LHS without parentheses on it; and this isn't
something that is due to a glitch in the ISO C grammar that is removable
by a compiler implementor, since a = b = c means a = (b = c).
Assignment is syntactially symmetric at the AST level only, where
parentheses don't matter any more.
It's possible to generate an AST that has an '=' node with any kind
of expressions as left and right children, and then check it for
valid left sides as a matter of syntax.
If the surface language before the AST is some Lisp-like, then
the symmetry extends to that syntax also, which can just be (set <expr>
<expr>); it parses regardless of what the expressions are.
Unless you take symmetry too literally: obviously (set <expr-1>
<expr-2>) is not symmetric with regard to (<expr-2> <expr-1> set). :)
Not to mention (<2-rpxe> <1-rpxe> tes). :)
The "assignment is symmetric at the syntax level" is a kind of Lisp
mindset, which has banished precedence and associativity.
In Common Lisp (and some other dialects), the application program
can extend the repertoire of what kind of expression is a "place";
i.e. can appear as the left argument of an assignment operator,
and be used in other related operators.
In Common Lisp, I can make (setf (+ a 1) 42) do something. For
instance, I can have it set a to 41, so that (+ a 1) yields 42.
Note that if I chose this specific semantics, it will still not allow
(setf (+ 2 2) 42). The + expression will have to contain at least one
term that is itself a place. (Perhaps we can choose the leftmost
place as the one to operate on so that (setf (+ a b) ...) will
operate on a).
I belong to the Lisp mindset, so I tend to agree with the basic gist
of your idea. Tou've chosen to work in languages where your intuitions
do not work out to being literally true, though. :)
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca