Does it make sense?
I should be really in D.learn but asked that here in context ;)
Sounds like most of us should be in D Learn on this topic.
I should find the time to write up a case for Andrei's
suggestion. I have no problem with the compiler telling me that
my code is ambiguous, in fac
On Friday, 22 November 2013 at 00:50:25 UTC, John J wrote:
On 11/21/2013 02:20 PM, monarch_dodra wrote:
When you import from a module, you only need to specify the
module name
if there is ambiguity. So for example:
//
import std.array;
void main()
{
split("hello"); //OK!
}
//
im
On 11/21/2013 01:36 PM, Steve Teale wrote:
I thought that compilers were supposed to help you if you did ambiguous
things. An interesting example is:
int bar(int n)
{
return n+1;
}
int bar(int n)
{
return n+2;
}
void main()
{
int v = 22;
int n = bar(22);
}
Compiler helps her
On 11/21/2013 02:20 PM, monarch_dodra wrote:
When you import from a module, you only need to specify the module name
if there is ambiguity. So for example:
//
import std.array;
void main()
{
split("hello"); //OK!
}
//
import std.array;
import std.algorithm;
void main()
{
spl
On 11/21/2013 02:20 PM, monarch_dodra wrote:
When you import from a module, you only need to specify the module name
if there is ambiguity. So for example:
//
import std.array;
void main()
{
split("hello"); //OK!
}
//
import std.array;
import std.algorithm;
void main()
{
spli
On Thursday, 21 November 2013 at 07:22:39 UTC, Steve Teale wrote:
import std.stdio;
enum Intention
{
EVIL,
NEUTRAL,
GOOD,
SAINTLY
}
void foo(Intention rth)
{
if (rth == EVIL)
writeln("Road to hell");
}
void main()
{
foo(EVIL);
}
Why does the compiler complain in both
On Thursday, 21 November 2013 at 18:44:39 UTC, Steve Teale wrote:
On Thursday, 21 November 2013 at 17:39:28 UTC, Andrei
Alexandrescu wrote:
On 11/21/13 8:48 AM, Steve Teale wrote:
Could 'with' be extended to cover enum names do you think?
Also a
supplementary question - does auto lock out some
On Thursday, 21 November 2013 at 08:05:03 UTC, Michal Minich
wrote:
On Thursday, 21 November 2013 at 07:42:48 UTC, Craig Dillabaugh
wrote:
I should also mention, this post likely better belongs in:
digitalmars.D.learn
I don't entirely think so. I think the OP is arguing that D
should be able
That should be:
if( rth == Intention.EVIL ) and
foo( Intention.EVIL );
Phobos is less picky than the compiler. Try this:
import std.stdio;
enum Intention
{
EVIL,
NEUTRAL,
GOOD,
SAINTLY
}
void foo(Intention rth)
{
if (rth == Intention.EVIL)
writefln("The road to hell is
On Thursday, 21 November 2013 at 17:19:18 UTC, inout wrote:
On Thursday, 21 November 2013 at 07:22:39 UTC, Steve Teale
wrote:
import std.stdio;
enum Intention
{
EVIL,
NEUTRAL,
GOOD,
SAINTLY
}
void foo(Intention rth)
{
if (rth == EVIL)
writeln("Road to hell");
}
void main()
{
BOOM! Code no longer compiles.
As a rule, the code that compiles and works should preserve
its behavior when new code is added, so this is prohibited.
Also please post to D.learn
forgot to add:
void foo(OtherIntention rth) { ... }
Which of the two is being called by main?
I thought that
On Thursday, 21 November 2013 at 17:39:28 UTC, Andrei
Alexandrescu wrote:
On 11/21/13 8:48 AM, Steve Teale wrote:
Could 'with' be extended to cover enum names do you think?
Also a
supplementary question - does auto lock out some things like
this, are
there other examples?
Guess it could. One
On Thursday, 21 November 2013 at 17:39:28 UTC, Andrei
Alexandrescu wrote:
On 11/21/13 8:48 AM, Steve Teale wrote:
Could 'with' be extended to cover enum names do you think?
Also a
supplementary question - does auto lock out some things like
this, are
there other examples?
Guess it could. One
On Thursday, 21 November 2013 at 16:48:59 UTC, Steve Teale wrote:
Could 'with' be extended to cover enum names do you think? Also
a supplementary question - does auto lock out some things like
this, are there other examples?
Is this what you mean?
enum Intention
{
EVIL,
NEUTRA
On 11/21/13 8:48 AM, Steve Teale wrote:
Could 'with' be extended to cover enum names do you think? Also a
supplementary question - does auto lock out some things like this, are
there other examples?
Guess it could. One other thing we could do is to make enum namespaces
behave like imports.
A
On Thursday, 21 November 2013 at 08:37:32 UTC, Craig Dillabaugh
wrote:
Yes, perhaps that was his intention (no pun intended). First few
times I used enums in D I was caught because I expected the
behavior he is suggesting here would work.
Pun was intended ;=)
On Thursday, 21 November 2013 at 08:05:03 UTC, Michal Minich
wrote:
On Thursday, 21 November 2013 at 07:42:48 UTC, Craig Dillabaugh
wrote:
I should also mention, this post likely better belongs in:
digitalmars.D.learn
I don't entirely think so. I think the OP is arguing that D
should be able
On Thursday, 21 November 2013 at 07:42:48 UTC, Craig Dillabaugh
wrote:
I should also mention, this post likely better belongs in:
digitalmars.D.learn
I don't entirely think so. I think the OP is arguing that D
should be able to identify symbol as specific enum's field when
used:
- in place
On Thursday, 21 November 2013 at 07:22:39 UTC, Steve Teale wrote:
import std.stdio;
enum Intention
{
EVIL,
NEUTRAL,
GOOD,
SAINTLY
}
void foo(Intention rth)
{
if (rth == EVIL)
writeln("Road to hell");
}
void main()
{
foo(EVIL);
}
Why does the compiler complain in both
On Thursday, 21 November 2013 at 07:28:14 UTC, Craig Dillabaugh
wrote:
On Thursday, 21 November 2013 at 07:22:39 UTC, Steve Teale
wrote:
clip
Why does the compiler complain in both places about EVIL. Can
it not work out which EVIL I mean? There's only one choice.
That should be:
if( rth =
On Thursday, 21 November 2013 at 07:22:39 UTC, Steve Teale wrote:
import std.stdio;
enum Intention
{
EVIL,
NEUTRAL,
GOOD,
SAINTLY
}
void foo(Intention rth)
{
if (rth == EVIL)
writeln("Road to hell");
}
void main()
{
foo(EVIL);
}
Why does the compiler complain in both
import std.stdio;
enum Intention
{
EVIL,
NEUTRAL,
GOOD,
SAINTLY
}
void foo(Intention rth)
{
if (rth == EVIL)
writeln("Road to hell");
}
void main()
{
foo(EVIL);
}
Why does the compiler complain in both places about EVIL. Can it
not work out which EVIL I mean? There's
22 matches
Mail list logo