idea for Native D Tuple Syntax, packing and unpacking

Kindly Doright kindly.doright at no-e-mail.com
Wed Jun 26 11:08:49 UTC 2024


On Wednesday, 26 June 2024 at 09:04:28 UTC, Stefan Koch wrote:
> On Tuesday, 25 June 2024 at 10:40:18 UTC, Kindly Doright wrote:
>> On Sunday, 23 June 2024 at 04:10:35 UTC, Kindly Doright wrote:
>>> // idea for Native D Tuple Syntax, packing and unpacking
>
> Hi Kindly,
>
> it seems your proposed syntax bears similarity to smalltalk.
> Are you a smalltalker by any chance?

I've not used smalltalk. I have been watching many of the D 
language videos and D conference videos.

I saw a recent video describing the prolonged effort to bring 
tuple unpacking to the D language (what syntax to use and its 
intended purpose).  In that video, Walter approved (via chat) the 
use of parenthesis syntax for tuple unpacking. And I had already 
observed the pros and cons expressed earlier online of using 
other D syntax (arrays, scopes, etc).

With my prior use of a vast array of languages and DSLs, I 
immediately recognized that the use of parenthesis (the right 
choice of syntax pair for D, btw) and its further context 
overloading...
    ...was going to be a compiler context nightmare and an 
extensive maintenance issue for years.  (Not to mention the 
increased obscurity in glancing at D code and discern what was 
occurring.)

The next morning, I awoke suddenly **at 4:30am** with this syntax 
in mind "#() = #()". It was a distinct language construct, clear 
of purpose, and reasonably simple to implement and maintain in a 
compiler. And yet, due to online communities eschewing outside 
ideas, I mentally tabled it.

**By 11:00am**, the concept kept niggling at me (almost harassing 
me). I sighed as I relented, and I took the deep dive to assess 
whether the syntax was actually compatible and viable with D 
(across the entire language scope). I also considered a few 
syntax variations, but they proved to be incompatible or 
syntactically misleading.

**By 1:30pm**, I had proven to myself that "#()" packing and 
unpacking was viable for tuples.

**By 2:00pm**, I again shelved the whole concept and went back to 
my own tasks.

**Around 5:00pm**, I became convicted of conscience that I should 
share the idea. And yet, modern online communities... so, again I 
replied to self, "No, thank you kindly."

**Late evening** arrives and I'm awakened by conscience (a 
conviction of kindness for this generation of developers, and 
especially D). So I search the D forums for the most appropriate 
place. Lo and behold, "DIP Ideas." I prepared a succinct example, 
something to concisely share, and then to be quietly done.

I was so deeply pleased that I didn't have to create an online 
account, and that I could share politely and anonymously. T h a n 
k - y o u  for that!

-----------
The current '2018' draft for tuple unpacking is highly complex, 
solving for every possible generic use case of the syntax.

The concept that I offer as an inspiration... is simplicity of 
scope and implementation, and an ease of reading and writing.

Anything that reduces cognitive load is considered an Advanced 
Feature in most industries. And packing and unpacking tuples 
solves an immediate coding need... when already undertaking a 
complex task.
(that is, I suddenly have the need to return unsimilar values 
from a function or process, or to access only a portion of a 
result set.   ALL WITHOUT creating an ad-hoc struct to ferry them 
about.)

Quirin Schroll's response revealed to me my implementation flaw 
of a multi-layer pack/unpack.  In short, "#()" syntactically 
should never be allowed inside of other parentheses.

As an inspirational idea, be inspired to explore it... and then 
utilize and adapt whatever beneficially good portions of it there 
may be.

Thank you kindly,
   -- Kindly

-----------
Stefan,
     Thank you for saying hello.
   -- Kindly




More information about the dip.ideas mailing list