www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Question to Walter

reply "Andrew Fedoniouk" <news terrainformatica.com> writes:
Can I rely on the fact that function

char[] toString(int i)

could be invoked as

int i = 23;
char[] s = i.toString();

By now it compiles successfully and works.

Thanks in advance.

Andrew Fedoniouk.
Feb 13 2005
next sibling parent reply "Ivan Senji" <ivan.senji public.srce.hr> writes:
"Andrew Fedoniouk" <news terrainformatica.com> wrote in message
news:cuocbn$1qhd$1 digitaldaemon.com...
 Can I rely on the fact that function

 char[] toString(int i)

 could be invoked as

 int i = 23;
 char[] s = i.toString();

 By now it compiles successfully and works.
What?? I can't get it to work! I tried with dmd 0.113. It would be nice if it did work but as far as i know it only works for arrays and even that isn't documented.
 Thanks in advance.

 Andrew Fedoniouk.
Feb 13 2005
parent reply "Andrew Fedoniouk" <news terrainformatica.com> writes:
You are right, Ivan.

It works only for arrays. :(
Mea culpa.

But would be nice if will work for any type.

The best way I can see is to be able to define

char[] int.toString()  { return itoa(this, .....) }


Andrew Fedoniouk.


"Ivan Senji" <ivan.senji public.srce.hr> wrote in message 
news:cuof9r$1tob$1 digitaldaemon.com...
 "Andrew Fedoniouk" <news terrainformatica.com> wrote in message
 news:cuocbn$1qhd$1 digitaldaemon.com...
 Can I rely on the fact that function

 char[] toString(int i)

 could be invoked as

 int i = 23;
 char[] s = i.toString();

 By now it compiles successfully and works.
What?? I can't get it to work! I tried with dmd 0.113. It would be nice if it did work but as far as i know it only works for arrays and even that isn't documented.
 Thanks in advance.

 Andrew Fedoniouk.
Feb 13 2005
parent "Ivan Senji" <ivan.senji public.srce.hr> writes:
"Andrew Fedoniouk" <news terrainformatica.com> wrote in message
news:cuojlg$21o7$1 digitaldaemon.com...
 You are right, Ivan.

 It works only for arrays. :(
 Mea culpa.
I knew it was a dream too good to be true :)
 But would be nice if will work for any type.

 The best way I can see is to be able to define

 char[] int.toString()  { return itoa(this, .....) }
This changes a lot of things like parsing... char[] toString(int) would be just great.
 Andrew Fedoniouk.
Feb 14 2005
prev sibling next sibling parent "Ivan Senji" <ivan.senji public.srce.hr> writes:
"Andrew Fedoniouk" <news terrainformatica.com> wrote in message
news:cuocbn$1qhd$1 digitaldaemon.com...
 Can I rely on the fact that function

 char[] toString(int i)

 could be invoked as

 int i = 23;
 char[] s = i.toString();

 By now it compiles successfully and works.
Can you please post your code beacuse all i get is: \proba2.d(13): cannot implicitly convert expression 1() of type int to char[] \proba2.d(13): function expected before (), not 'int' \proba2.d(13): no property 'toString' for type 'int' Line 13 is where the function is called.
 Thanks in advance.

 Andrew Fedoniouk.
Feb 13 2005
prev sibling parent reply David L. Davis <SpottedTiger yahoo.com> writes:
In article <cuocbn$1qhd$1 digitaldaemon.com>, Andrew Fedoniouk says...
Can I rely on the fact that function

char[] toString(int i)

could be invoked as

int i = 23;
char[] s = i.toString();

By now it compiles successfully and works.

Thanks in advance.

Andrew Fedoniouk.
Walter: I just saw a post from you a few minutes ago, where you replied "Yes." to this post from Andrew. But with the removal your reply, does that then mean you're saying "No?" I've tried the above example as: And I get the following errors: test_13feb.d(7): no property 'toString' for type 'int' test_13feb.d(7): function expected before (), not 'int' test_13feb.d(7): cannot implicitly convert expression 1() of type int to char[] Though I do recall seeing a thread here a few days ago, saying that this kind of code would work. Did dmd v0.113 change this? David L. ------------------------------------------------------------------- "Dare to reach for the Stars...Dare to Dream, Build, and Achieve!"
Feb 13 2005
parent "Andrew Fedoniouk" <news terrainformatica.com> writes:
Hi, David.

My code was just a dream...
Please see my answer to Ivan.

Andrew Fedoniouk. 
Feb 13 2005