May 29, 2004
Walter wrote:

> Yes, any type can be implicitly converted to void. -Walter

And any type can also be implicitly converted to Object as well, correct?  Why the addition of implicit void conversions?

Sean
May 29, 2004
"Sean Kelly" <sean@f4.ca> wrote in message news:c9ammk$1ri$1@digitaldaemon.com...
> Walter wrote:
>
> > Yes, any type can be implicitly converted to void. -Walter
>
> And any type can also be implicitly converted to Object as well, correct?

No, only objects derived from Object.

>  Why the addition of implicit void conversions?

To make it easy to return an expression from a void function.

> Sean


May 29, 2004
"Walter" <newshound@digitalmars.com> wrote in message news:c9aj4e$2ukl$1@digitaldaemon.com...
> Yes, any type can be implicitly converted to void. -Walter

Thanks! By the way: is there any way to convert it void to another type?

> "Ivan Senji" <ivan.senji@public.srce.hr> wrote in message news:c99hap$1f97$1@digitaldaemon.com...
> > Great: "Allow functions that return void to return expressions. " I was for this too BUT:
> >
> > import std.c.stdio;
> >
> > class A{}
> >
> > void F1(int x)
> > {
> >  printf("F1(%d)\n",x);
> >  return new A();
> > }
> >
> > void F2(int x)
> > {
> >  printf("F2(%d)\n",x);
> >  return F1(x);
> > }
> >
> > int main ( char [] [] args )
> > {
> >  F2(100);
> > }
> >
> > This code compiles ok. It seams that a function returning void can
> > now return anything, is it the expected behaviour?
> > I would expect the return in F1 not to work and the one in F2 to work?
> >
> >
> > "Walter" <newshound@digitalmars.com> wrote in message news:c98ju4$17o$1@digitaldaemon.com...
> > > Mainly more bug fixes.
> > >
> > > http://www.digitalmars.com/d/changelog.html
> > >
> > >
> > >
> > >
> >
> >
>
>


May 29, 2004
"Ivan Senji" <ivan.senji@public.srce.hr> wrote in message news:c9atft$bld$1@digitaldaemon.com...
> "Walter" <newshound@digitalmars.com> wrote in message news:c9aj4e$2ukl$1@digitaldaemon.com...
> > Yes, any type can be implicitly converted to void. -Walter
>
> Thanks! By the way: is there any way to convert it void to another type?

No.


May 31, 2004
In article <c9aq9h$79m$1@digitaldaemon.com>, Walter wrote:
>>  Why the addition of implicit void conversions?
> 
> To make it easy to return an expression from a void function.

Why would you want to? Unless its type is void, of course, but then you don't need an implicit void conversion in the first place.

-Antti

-- 
I will not be using Plan 9 in the creation of weapons of mass destruction to be used by nations other than the US.
May 31, 2004
"Antti Sykäri" <jsykari@gamma.hut.fi> wrote in message news:slrncbl07d.o2l.jsykari@pulu.hut.fi...
> In article <c9aq9h$79m$1@digitaldaemon.com>, Walter wrote:
> >>  Why the addition of implicit void conversions?
> >
> > To make it easy to return an expression from a void function.
>
> Why would you want to? Unless its type is void, of course, but then you don't need an implicit void conversion in the first place.

I'm not sure if it was a good idea or not :-(


May 31, 2004
In article <c9elv9$2e5f$1@digitaldaemon.com>, Walter says...
>
>
>"Antti Sykäri" <jsykari@gamma.hut.fi> wrote in message news:slrncbl07d.o2l.jsykari@pulu.hut.fi...
>> In article <c9aq9h$79m$1@digitaldaemon.com>, Walter wrote:
>> >>  Why the addition of implicit void conversions?
>> >
>> > To make it easy to return an expression from a void function.
>>
>> Why would you want to? Unless its type is void, of course, but then you don't need an implicit void conversion in the first place.
>
>I'm not sure if it was a good idea or not :-(
>
>

This is what's needed. You need to imagine the concept of an expression with type void. There should be *only* two ways to create such an expression;

(1)     return;         // returns an expression of type void;
(2)     return expr;    // see below

The second possibility returns an expression of type void IF AND ONLY IF expr is itself an expression of type void, otherwise it's a compile error. It's that simple.

PS. C allows the following. I don't think we should copy it.

>       int f(int x)
>       {
>           (void) x;
>           /* stuff */
>       }

The intent here is to disable compiler warnings about x not being used.


June 04, 2004
Ant wrote:
> On Fri, 28 May 2004 16:52:45 -0700, Walter wrote:
> 
> 
>>Mainly more bug fixes.
>>
>>http://www.digitalmars.com/d/changelog.html
> 
> 
> from the change log:
> 
> 
>>typeof(this).member() now does non-virtual call to member().
> 
> 
> bad idea, bad sintax.
> 
> Ant

What about this syntax?

this.(ClassName.member)()

I know that it doesn't look right, but it does express exactly what you intend: call this specific implementation using the 'this' pointer.

1 2
Next ›   Last »