On 31/12/2018 19:22, Rick C. Hodgin wrote:
> On 12/31/2018 1:07 PM, Bart wrote:
>> # Concatenation of some sort
>
> For readability. It allows a single operator to span multiple sources,
> with each one being together with its cohort in the nth position. The
> example I use is (c1#c2 == 13#10), rather than (c1 == 13 && c2 == 10).
> It conveys more clearly you're looking for a 13/10 (CR/LF) pair in two
> variables, where as c1 == 13 && c2 == 10 breaks it out and it's not
> completely clear.
In my dynamic language, there is no specific operator like this, but
there are several ways of expressing that using existing features:
if (c1,c2) = (13,10) then # compare two lists
if c1..c2 = 13..10 than # compare two ranges (ordering
# doesn't matter here)
case (c1,c2)
when (13,10) then # test 1st of several pairs
Such syntax can be adapted for static code. The advantage is that is
much clearer what is being attempted.
>> !+ +! ?
>
> I don't remember these. I think they were going to be nested comments.
> I've since changed the syntax to be /+ and +/ to follow D's syntax.
>
>> [x] Same as *x
Assuming you are still using * from C, that means that for dereferencing
a pointer to struct member, you can use:
(*p).m
p->m
m<-p
[p].m
p~~m
For dereferencing a double pointer to a struct member, the choices are:
(*(*q)).m
(*q)->m
m<-(*q)
[[q]].m
[q]->m
m<-[q]
q~~m # ???
You see the problem? The syntax I use has ONE way to dereference a
pointer (postfix "^"), and ONE way to select a member ("."):
These examples must be written
p^.m # one pointer level, one ^
q^^.m # two pointer levels, two ^
Both access one member, so both have one ".". Take out member select:
p^ # access the whole struct
q^^
Try and take out the member select part of the 10 or 12 examples in your
syntax; you can't just remove the ".m", because most of them don't use it.
C syntax has always been a mess that way. Your additions make it worse.
>> <|...|>
>> [|...|]
>> (|...|)
>> /|...|/
>> \|...|/
>
> Each has a particular purpose. ~|utility|~ for ad hoc code. <|logic|>
> for decisions, or responding to flow control. [|definition|] for def-
> ining things. (|reference|) for referencing things.
Who's ever going to remember that lot? And don't tell me the last two,
/|...|/ and \|...|/ aren't going to get mixed up, unless that was a typo
and the last was meant to be \|...|\ (although all of them are a
complete pain to type).
To add attributes, just have the ONE syntax. The name of the attribute
will tell you which kind it is.
> Pointers can go either way a->b or b<-a. It's provided to give con-
In Algol 68, p.m or p->m would be written as m OF p. (There is no
explicit dereferencing.) But it has just the one choice.) Most languages
went with variations on p.m.
> All variables have an implicit underscore variable form unless there
> is an explicitly created underscore variable name in scope. If you
> create "char* x" there's an implicit _x which is the unsigned integer
> equivalent value that can be used.
Say again? I expected you to say that _x means *x, some syntactic sugar.
You mean that _x means '*(unsigned char)x'?
(My old language could do the first example like this:
ref char x
ref. char _x @x
char c:='A'
x := &c
print x # display pointer address
print x^ # display A
print _x # display A
Again, features of more general use. The "." in the second line
indicated an auto-deref point. This has now been dropped, while @
(equivalence) only works for a native target.)
>> ? As in 'if (x?)'
>
> An immediate evaluation of x to 0, and returns true or false. It is
> not required, but has utility in something like "if (x? == validState)".
> It's the same as "if ((x != NULL) == validState)".
I actually have this in the form of 'istrue'. But it is so rarely used
that I had to try it to see if it was available in user code.
In any case, C programs can use 'if (!!x)' for exactly this purpose.
>> b<-a Means same as a->b
>> |-, -| ? 'lbar' and 'rbar'
>
> Same as <- and ->, except they categorize the data in the struct
> or class as being primary members, or lesser used members. An
> lbar or rbar member is typically set at instantiation, and then
> not altered. It's designed to provide a visual cue that this data
> is different than other oft-changing data.
Ugh. How about some features that simplify coding and make it easier to
write, read, and understand?
>> #x 'before value of x'?
>
> During an assignment, it allows the value to be conveyed with
> its before-assignment value, such as "if ((x == f()))" would
> now return the value of f(x), but it allows the prior value
> of x before it was assigned.
I think this was discussed before in this group. No one could come up
with a suitable syntax for it, and #x isn't it.
It's a kind of assignment inside an expression, which returns the value
of the lhs before it was assigned to.
> I've also added "bit = x?<<;" to do a bit scan and report the
> position where the first bit is set. Same with "bit = >>?x;"
> to scan down from msb to lsb.
What's the point of all these cryptic symbol that might be used once in
a blue moon? There would be so long between each use, that you will have
long forgotten what x?<< was ever supposed to be.
x64 calls these ops BSF and BSR. Or bitscanforward and bitscanreverse.
Just use those names, and no one will ever need to scratch their head
about them.
> I've also added ^ parent pointers, so you can reference an
> encapsulating structure when you know the pointer or variable
> you're referencing is contained in a parent structure.
This is typical of your explanations that I have to read several and
still can't grok the meaning or purpose of your feature.
Maybe I am particularly thick, or not very receptive to new ideas. Or
maybe I am fairly typical and this is a poor feature that is hard to get
your head around.
>>> I've added the /% divide-modulo operator, which operates to
>>> obtain the divide value and remainder in one op:
>>>
>>> // Using divide-modulo
>>> divide_value = a /% b : remainder;
>>
>> (Your use of ":" interferes with "?:" if you still have that.)
>
> The ?: syntax has the ?, then the colon. This syntax only has
> the colon.
Can /% be used anywhere an expression can be, or only in conjunction
with "="? If the former, than /% and ?: can be used in the same
expression and there can be clashes.
Even if only as above, then someone can write:
x = a ? b /% c : d ? e @ r : d;
I think the problem is clear.
--
bart