Proposal: struct and array literal syntax
Daniel Keep
daniel.keep.list at gmail.com
Fri Jun 23 23:02:00 PDT 2006
Bruno Medeiros wrote:
> Andrei Khropov wrote:
>
>> Boris Wang wrote:
>>
>>> "Andrei Khropov" <andkhropov at nospam_mtu-net.ru>
>>> P4HkO{O"PBNE:e7b7fb$277d$1 at digitaldaemon.com...
>>>
>>>> Derek Parnell wrote:
>>>>
>>>>> Now a 'rectangular' array ...
>>>>>
>>>>> int[][]![
>>>>> int[]![1,2,3,4],
>>>>> int[]![5,6,7,8],
>>>>> int[]![9,0,1,2],
>>>>> int[]![3,4,5,6],
>>>>> ]
>>>>>
>>>>> Hmmm ... appears to do okay.
>>>>
>>>> Well, in the last case inner int[]! s appear to be a syntactic
>>>> overhead.
>>>>
>>>> I'm still waiting for better handling of multidimensional rectangular
>>>> arrays (not less effective "jagged").
>>>>
>>>> -- AKhropov
>>>>
>>> May be:
>>>
>>> int[][]![
>>> ![1,2,3,4],
>>> ![5,6,7,8],
>>> ![9,0,1,2],
>>> ![3,4,5,6],
>>> ]
>>>
>>> the type of ![1,2,3,4] can be inferred.
>>
>>
>> In the spirit of the recent type inference extensions the outer type
>> should be
>> inferred also: just
>>
>> ![
>> ![1,2,3,4],
>> ![5,6,7,8],
>> ![9,0,1,2],
>> ![3,4,5,6]
>> ]
>>
>
> All this talk makes kinda wish that the ascii tables (and consequently
> the standard keyboards as well) had one more set of brackets, like the
> angle brackets for example
> (http://en.wikipedia.org/wiki/Bracket#Angle_brackets_or_chevrons_.E2.8C.A9.C2.A0.E2.8C.AA),
> used for tuple notation in math. "〈1, 2〉"
>
> A comparison:
>
> <1, 2>
> ‹1, 2›
> «1, 2»
> 〈1, 2〉 // Why do these take two spaces?
> 《1, 2》
>
AFAIK, they take spaces because they are "fullwidth" asian characters.
I think it comes from most western glyphs being vertical rectangles, and
most asian glyphs being square-ish. So they make the characters twice
as wide :)
As for more brackets: hell yeah. I think there are three things that
really limit programming languages: lack of special characters that will
reliably be on many computers, lack of special characters on our
keyboards, and programming language's fixation on using special
characters :P
I think that what would help is adding these features with whatever
syntax we can muster, and add alises for these using extended characters
where we can find them.
Maybe if we start supporting more than basic ASCII now, someday we'll
get better keyboards :)
-- Daniel
More information about the Digitalmars-d
mailing list