[Issue 3971] Syntax & semantics for array assigns

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Dec 6 03:24:33 PST 2010


http://d.puremagic.com/issues/show_bug.cgi?id=3971


Stewart Gordon <smjg at iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg at iname.com


--- Comment #16 from Stewart Gordon <smjg at iname.com> 2010-12-06 03:22:53 PST ---
(In reply to comment #0)
> a[] = b[];  static  dynamic
> static      OK1     OK1
> dynamic     OK1     OK1
> 
> a = b[];    static  dynamic
> static      Err     Err
> dynamic     Err     Err
> 
> a[] = b;    static  dynamic
> static      Err     Err
> dynamic     Err     Err
> 
> a = b;      static  dynamic
> static      Err2    Err
> dynamic     Err     OK2

I'm not sure I like this.  What, exactly, would be the semantic difference
between the rvalue b and the rvalue b[]?  Currently, they are the same, and
changing this might be confusing.

> int i; a=i; static  dynamic
>             Err     Err
> 
> int i;
> a[] = i;    static  dynamic
>             OK3     OK3

This is how D behaves currently.

> Key:
>   Err =  Syntax error
>   OK1 =  Copies all items from an array to the oter.
>   OK2 =  Copies just the stuct of the dynamic array, array body not copied.
>   OK3 =  Copies the value to all the items of the array.
>   Err2 = Syntax error, becase there is no reference to copy, better to keep
> tidy the language.

Making it a _syntax_ error cannot be done, because D's grammar is context-free
by design.

> 
> You can see that this too is disallowed:
> int a, b;
> a = b;

???

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list