Jump to page: 1 2
Thread overview
DMD 0.101 release
Aug 31, 2004
Walter
Aug 31, 2004
h3r3tic
Aug 31, 2004
Nick
Aug 31, 2004
Sean Kelly
Aug 31, 2004
Walter
Aug 31, 2004
Nick
Sep 01, 2004
Stewart Gordon
Sep 01, 2004
Ben Hinkle
Sep 01, 2004
Cappa-Gamma
Sep 01, 2004
Ben Hinkle
Sep 01, 2004
Cappa-Gamma
August 31, 2004
http://www.digitalmars.com/d/changelog.html


August 31, 2004
wow!, thanks Walter, you have exterminated all - 1 of my bugs :] but this code still doesn't compile :(

void foo()
{
	class Foo
	{
		int x;
	}
}

void bar()
{
	class Foo
	{
		int y;
	}
	
	Foo f = new Foo;
	f.y = 5;
}

void main()
{
}

// foo.d(17): no property 'y' for type 'Foo'
August 31, 2004
In article <ch0n9t$5k8$1@digitaldaemon.com>, Walter says...
>
>http://www.digitalmars.com/d/changelog.html

"Missing function body after 'in' now diagnosed."

I just realized I had the following code lying around (it doesn't compile
anymore.) :

# abstract double random()
# out(result)
# {
#   assert( (0 < result) && (result < 1) );
# };

I know in/out contracts aren't inherited yet, so the out block has no effect. But when inheritance _is_ implemented, shouldn't the above be allowed?

Nick


August 31, 2004
In article <ch22l8$qs8$1@digitaldaemon.com>, Nick says...
>
>In article <ch0n9t$5k8$1@digitaldaemon.com>, Walter says...
>>
>>http://www.digitalmars.com/d/changelog.html
>
>"Missing function body after 'in' now diagnosed."
>
>I just realized I had the following code lying around (it doesn't compile
>anymore.) :
>
># abstract double random()
># out(result)
># {
>#   assert( (0 < result) && (result < 1) );
># };
>
>I know in/out contracts aren't inherited yet, so the out block has no effect. But when inheritance _is_ implemented, shouldn't the above be allowed?

"abstract" is kind of weird.  It's entirely possible to do this right now:

# class Test
# {
# public:
#     abstract double random()
#     out(result)
#     {
#       assert( (0 < result) && (result < 1) );
#     }
#     body
#     {
#         return 0.0;
#     }
# }
#
# int main()
# {
#     Test d = new Test();
#     d.random();
#     return 0;
# }

IMO this should fail to compile with a message like "cannot instantiate abstract class", but it doesn't (ie. I expect abstract functions to work just like pure virtual functions in C++).  Still, an easy workaround for your situation is to define a body that returns something that fails the output contract, as I did above.


Sean


August 31, 2004
"Nick" <Nick_member@pathlink.com> wrote in message news:ch22l8$qs8$1@digitaldaemon.com...
> In article <ch0n9t$5k8$1@digitaldaemon.com>, Walter says...
> >
> >http://www.digitalmars.com/d/changelog.html
>
> "Missing function body after 'in' now diagnosed."
>
> I just realized I had the following code lying around (it doesn't compile
> anymore.) :
>
> # abstract double random()
> # out(result)
> # {
> #   assert( (0 < result) && (result < 1) );
> # };

I'm sure it didn't work before, either.

> I know in/out contracts aren't inherited yet, so the out block has no
effect.
> But when inheritance _is_ implemented, shouldn't the above be allowed?

Hmm. I can't think why not.


August 31, 2004
In article <ch2ak8$v2k$1@digitaldaemon.com>, Walter says...
>>
>> # abstract double random()
>> # out(result)
>> # {
>> #   assert( (0 < result) && (result < 1) );
>> # };
>
>I'm sure it didn't work before, either.
>

It didn't actually _work_, no, but it did compile. I left it there so it would work in the future, when in/out inheritance was implemented. For now I've just commented it out.

Nick


September 01, 2004
Walter wrote:

> http://www.digitalmars.com/d/changelog.html

"Function literals can now have same type signature."

Same as what?

Stewart.

-- 
My e-mail is valid but not my primary mailbox.  Please keep replies on the 'group where everyone may benefit.
September 01, 2004
Stewart Gordon wrote:

> Walter wrote:
> 
>> http://www.digitalmars.com/d/changelog.html
> 
> "Function literals can now have same type signature."
> 
> Same as what?
> 
> Stewart.
> 

Same as each other. I think there was a bug where two function literals in
the same scope couldn't have the same signature. So
void foo() {
 x = function int(){...};
 y = function int(){...};
}
wouldn't compile because of conflicting function names. My guess is that's
the bug that got fixed.

September 01, 2004
Hmmm, compiling this though :

###
module foo;

import std.stream;

void main ()
{
void function() x, y;
x = function void() { stdout.writeLine("X!"); };
y = function void()  { stdout.writeLine("Y!"); };
x();
y();
}

Gives me the error :

c:\dmd\bin\..\..\dm\bin\link.exe foo,,,user32+kernel32/noi;
OPTLINK (R) for Win32  Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved

foo.obj(foo)  Offset 001B5H Record Type 00C3 Error 1: Previous Definition Different : _D3foo4main0FZv
--- errorlevel 1

??

Charlie


In article <ch4ehp$25sb$2@digitaldaemon.com>, Ben Hinkle says...
>
>Stewart Gordon wrote:
>
>> Walter wrote:
>> 
>>> http://www.digitalmars.com/d/changelog.html
>> 
>> "Function literals can now have same type signature."
>> 
>> Same as what?
>> 
>> Stewart.
>> 
>
>Same as each other. I think there was a bug where two function literals in
>the same scope couldn't have the same signature. So
>void foo() {
> x = function int(){...};
> y = function int(){...};
>}
>wouldn't compile because of conflicting function names. My guess is that's
>the bug that got fixed.
>


September 01, 2004
worked for me. Did you get dmd-0.101? Run dmd -v to find out.

"Cappa-Gamma" <Cappa-Gamma_member@pathlink.com> wrote in message news:ch513r$2em3$1@digitaldaemon.com...
> Hmmm, compiling this though :
>
> ###
> module foo;
>
> import std.stream;
>
> void main ()
> {
> void function() x, y;
> x = function void() { stdout.writeLine("X!"); };
> y = function void()  { stdout.writeLine("Y!"); };
> x();
> y();
> }
>
> Gives me the error :
>
> c:\dmd\bin\..\..\dm\bin\link.exe foo,,,user32+kernel32/noi;
> OPTLINK (R) for Win32  Release 7.50B1
> Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved
>
> foo.obj(foo)  Offset 001B5H Record Type 00C3
> Error 1: Previous Definition Different : _D3foo4main0FZv
> --- errorlevel 1
>
> ??
>
> Charlie
>
>
> In article <ch4ehp$25sb$2@digitaldaemon.com>, Ben Hinkle says...
> >
> >Stewart Gordon wrote:
> >
> >> Walter wrote:
> >>
> >>> http://www.digitalmars.com/d/changelog.html
> >>
> >> "Function literals can now have same type signature."
> >>
> >> Same as what?
> >>
> >> Stewart.
> >>
> >
> >Same as each other. I think there was a bug where two function literals
in
> >the same scope couldn't have the same signature. So
> >void foo() {
> > x = function int(){...};
> > y = function int(){...};
> >}
> >wouldn't compile because of conflicting function names. My guess is
that's
> >the bug that got fixed.
> >
>
>


« First   ‹ Prev
1 2