More D newb questions.

Derek Parnell derek at nomail.afraid.org
Wed May 7 23:07:57 PDT 2008


On Thu, 8 May 2008 05:11:14 +0100, Janice Caron wrote:

> On 07/05/2008, Me Here <p9e883002 at sneakemail.com> wrote:
>> Sorry to be pedantic in response, but in what way does it work?
>>
>>         import std.stdio;
>>
>>         void main() {
>>             char a = 'a', b = 'b';
>>             writefln( a ~ b );
>>         }
>>         c:\dmd\test>dmd junk3.d
>>         junk3.d(5): Error: Can only concatenate arrays, not (int ~ int)
> 
> By giving a compile error, of course. That's how it's /supposed/ to
> work. It's telling you to fix your code,

In order to be helpful to coders, maybe the text of the message could be a
bit more accurate ... something like ...

    junk3.d(5): Error: Can only concatenate arrays, not (char ~ char)

Yes, I know about integer promotion rules. The internal machinations of the
compiler need not be exposed to the source code writer, however. The coder
used 'char' so the message should use 'char'.

>  e.g. to
> 
>         void main() {
>             char[] a = ['a'], b = ['b'];
>             writefln( a ~ b );
>         }

I don't have D availble here so does this below work?

    void main() {
         char a = 'a', b = 'b';
          writefln( [a] ~ [b] );
      }

If not, it might be a neat idea.

-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
8/05/2008 4:04:09 PM



More information about the Digitalmars-d mailing list