View mode: basic / threaded / horizontal-split · Log in · Help
August 18, 2012
Stringy Weirdness
I haven't been quite able to figure this one out.

string[string][]       Dict;    //sure ok.
alias string[string][] dict;    //Error

void main()
{
    Dict                   = [["Cow":"moo" 
],["Duck":"quack"]];//cool
    Dict                  ~=  ["Dog":"woof"]                   
//No prob.
assert(Dict==[["Cow":"moo"],["Duck":"quack"],["Dog":"woof"]]);//looks 
legit
    dict temp              = [["Cow":"moo" 
],["Duck":"quack"]];//Error
    string[string][] temp2 = [["Cow":"moo" 
],["Duck":"quack"]];//Error


    //And My favorite one of all:
    auto temp2 = [["Cow":"moo"],["Duck":"quack"]];  //Error
}

I've hit stuff like this before, and I've always assumed it was 
just karma for screwing with it.  I can't figure out why it does 
this.
August 18, 2012
Re: Stringy Weirdness
On Sat, 18 Aug 2012 07:11:38 +0200, 1100110 <10equals2@gmail.com> wrote:

> I haven't been quite able to figure this one out.
>
> string[string][]       Dict;    //sure ok.
> alias string[string][] dict;    //Error
>
> void main()
> {
>      Dict                   = [["Cow":"moo" ],["Duck":"quack"]];//cool
>      Dict                  ~=  ["Dog":"woof"]                   //No  
> prob.
> assert(Dict==[["Cow":"moo"],["Duck":"quack"],["Dog":"woof"]]);//looks  
> legit
>      dict temp              = [["Cow":"moo" ],["Duck":"quack"]];//Error
>      string[string][] temp2 = [["Cow":"moo" ],["Duck":"quack"]];//Error
>
>
>      //And My favorite one of all:
>      auto temp2 = [["Cow":"moo"],["Duck":"quack"]];  //Error
> }
>
> I've hit stuff like this before, and I've always assumed it was just  
> karma for screwing with it.  I can't figure out why it does this.

These are definite bugs. Please file:

http://d.puremagic.com/issues/enter_bug.cgi

-- 
Simen
August 18, 2012
Re: Stringy Weirdness
On Sat, 18 Aug 2012 02:35:06 -0500, Simen Kjaeraas  
<simen.kjaras@gmail.com> wrote:

> On Sat, 18 Aug 2012 07:11:38 +0200, 1100110 <10equals2@gmail.com> wrote:
>
>> I haven't been quite able to figure this one out.
>>
>> string[string][]       Dict;    //sure ok.
>> alias string[string][] dict;    //Error
>>
>> void main()
>> {
>>      Dict                   = [["Cow":"moo" ],["Duck":"quack"]];//cool
>>      Dict                  ~=  ["Dog":"woof"]                   //No  
>> prob.
>> assert(Dict==[["Cow":"moo"],["Duck":"quack"],["Dog":"woof"]]);//looks  
>> legit
>>      dict temp              = [["Cow":"moo" ],["Duck":"quack"]];//Error
>>      string[string][] temp2 = [["Cow":"moo" ],["Duck":"quack"]];//Error
>>
>>
>>      //And My favorite one of all:
>>      auto temp2 = [["Cow":"moo"],["Duck":"quack"]];  //Error
>> }
>>
>> I've hit stuff like this before, and I've always assumed it was just  
>> karma for screwing with it.  I can't figure out why it does this.
>
> These are definite bugs. Please file:
>
> http://d.puremagic.com/issues/enter_bug.cgi
>

Is it supposed to do that or not?  that's what I can't decide...  =P

It doesn't seem to like templates either.  A tls variable, Tuple, or a  
Variant seems to be the only way that
string[string][] works.  It wants a double?  a number anyways.


-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/
August 18, 2012
Re: Stringy Weirdness
Issue 8557 has been added to the database




On Sat, 18 Aug 2012 02:35:06 -0500, Simen Kjaeraas  
<simen.kjaras@gmail.com> wrote:

> On Sat, 18 Aug 2012 07:11:38 +0200, 1100110 <10equals2@gmail.com> wrote:
>
>> I haven't been quite able to figure this one out.
>>
>> string[string][]       Dict;    //sure ok.
>> alias string[string][] dict;    //Error
>>
>> void main()
>> {
>>      Dict                   = [["Cow":"moo" ],["Duck":"quack"]];//cool
>>      Dict                  ~=  ["Dog":"woof"]                   //No  
>> prob.
>> assert(Dict==[["Cow":"moo"],["Duck":"quack"],["Dog":"woof"]]);//looks  
>> legit
>>      dict temp              = [["Cow":"moo" ],["Duck":"quack"]];//Error
>>      string[string][] temp2 = [["Cow":"moo" ],["Duck":"quack"]];//Error
>>
>>
>>      //And My favorite one of all:
>>      auto temp2 = [["Cow":"moo"],["Duck":"quack"]];  //Error
>> }
>>
>> I've hit stuff like this before, and I've always assumed it was just  
>> karma for screwing with it.  I can't figure out why it does this.
>
> These are definite bugs. Please file:
>
> http://d.puremagic.com/issues/enter_bug.cgi
>


-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/
August 18, 2012
Re: Stringy Weirdness
On Saturday, 18 August 2012 at 07:54:18 UTC, 1100110 wrote:
> Is it supposed to do that or not?  that's what I can't 
> decide...  =P
>
> It doesn't seem to like templates either.  A tls variable, 
> Tuple, or a Variant seems to be the only way that
> string[string][] works.  It wants a double?  a number anyways.

 Not it's not suppose to do that. An alias is just short hand for 
the longer version. If you can use it properly without the alias 
(but not with) than you have your answer. Fully expanded it's 
hard to read:P

 immutable(char)[immutable(char)[]][]

 It's like optimizations, they are added that change your code to 
be smaller, faster, inlined, using hardware tricks; But the usage 
and behavior of the code remains unchanged.
August 19, 2012
Re: Stringy Weirdness
But it *doesn't* work just fine without the alias.  =P

There are very specific things that *make* it work,
so I couldn't figure out if it was ever *supposed* to work.
Either the bug was the fact that it worked, or the bug was the fact that  
it didn't work.

immutable(char)[immutable(char)[]][] does not work at all.(*I* can't make  
it work)
alias currently (2.060) does not seem to work with AA at all.
auto currently does not work with AA.
array literals currently do not work with AA.

you cannot do string[string][] thing = [["t":"f"]];
but you *can* do string[string][] thing; thing = [["t":"f"]];//on the same  
line, no less...

you cannot do alias string[string][string] Dict;
and there doesn't seem to be a workaround.

you cannot do auto Dict = [["a":"b"]];
and there doesn't seem to be a workaround.


D really is amazing in that these features exist.
Work out all of the minor bugs and work on Documentation a little and we  
are in
"why the (insert explitive here) *aren't* you using D?" territory.

I do however find it unacceptable that a major language feature(AA) does  
not play nice
with other language features(auto, alias, array literals).

I think that this bug (8557, or 5448 if they are too similar) should be  
upgraded in severity.
There is even a patch for 5448 that (seems to have) languished.

We should either fix AA so that it works properly, drop it completely,  
or(less acceptable IMO)
add a huge (See BUG 8557, 5448) to the top of http://dlang.org/hash-map
(But that's just my opinion)

What do you think?

On Sat, 18 Aug 2012 03:59:44 -0500, Era Scarecrow <rtcvb32@yahoo.com>  
wrote:

> On Saturday, 18 August 2012 at 07:54:18 UTC, 1100110 wrote:
>> Is it supposed to do that or not?  that's what I can't decide...  =P
>>
>> It doesn't seem to like templates either.  A tls variable, Tuple, or a  
>> Variant seems to be the only way that
>> string[string][] works.  It wants a double?  a number anyways.
>
>   Not it's not suppose to do that. An alias is just short hand for the  
> longer version. If you can use it properly without the alias (but not  
> with) than you have your answer. Fully expanded it's hard to read:P
>
>   immutable(char)[immutable(char)[]][]
>
>   It's like optimizations, they are added that change your code to be  
> smaller, faster, inlined, using hardware tricks; But the usage and  
> behavior of the code remains unchanged.


-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/
ME: Opera, you ain't 'revolutionary'. That's like Apple claiming to be  
'innovative'.
Geez...
Top | Discussion index | About this forum | D home