August 15, 2004
"Ilya Minkov" <minkov@cs.tum.edu> wrote in message news:cfnkur$hqi$1@digitaldaemon.com...
> Ur, what?
>
> Who are you anyway?
>
> -eye/photoallergics


<sigh>

If you perhaps had a sense of joviality you would already know. Or, if you'd bother to look at prior posts, you would already know. My name is Kris, and, if you'll graciously concede to it, I'll post under whatever "alias" suits; just as others do.

That aside, I'm certainly entitled to my opinion. Just as you, apparently, are entitled to your rather staunch opinion over a variety of matters.

Further; if you had any sense of etiquette, you'd understand that it's considered rather 'uncool' to jostle individuals over their identity in a public forum. Or perhaps you were being pompously arrogant instead.

I'll bid you "good-day"




August 15, 2004
In article <cfoa52$unf$1@digitaldaemon.com>, antiAlias says...

>it's
>considered rather 'uncool' to jostle individuals over their identity in a
>public forum.

I agree with this, and I'd just like to remind everyone that the big W himself (in post http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/3072) said: "in general I'd like to request that we leave it up to the person using a handle to reveal themselves or not as their choice".

Jill


August 17, 2004
On Thu, 12 Aug 2004 06:56:43 +0000 (UTC), Arcane Jill <Arcane_member@pathlink.com> wrote:
> In article <opscld1nzg5a2sq9@digitalmars.com>, Regan Heath says...
>
>>> This is especially true if fooBar takes an int value and the enum is
>>> being implicitly cast.
>>
>> Ahh.. I didn't think of this. :)
>
> Yes you did. Or at least, your original idea, as I now understand it, completely
> covers this possibility. It works like this - assume your enum-type-detection
> system is up and running, then:
>
> #    enum Qwerty { ONE=1, TWO=2 };
> #    void f(int x) { /*whatever*/ }
> #    f(ONE);
>
> This is simply a compile error, because f takes an int, and therefore "with
> Qwerty" is not assumed when parsing f(ONE); Accordingly, ONE is simply an
> unknown identifier. To get it to compile, you'd have either to change line 3 to
> f(Qwerty.ONE); or else change line 2 to void f(Qwerty x);

True..

>> I have just discovered something slightly weird...
>>
>> enum Test : ubyte {
>>   ONE = 0x1,
>>   TWO = 0x2
>> }
>>
>> void foo(Test a)
>> {
>> }
>>
>> void main()
>> {
>>   foo(Test.ONE);
>>   foo(Test.ONE|Test.TWO);  //function foo (Test a) does not match argument
>> types (int)
>>                            //cannot implicitly convert expression
>> cast(int)(1)
>>                            // | cast(int)(2) of type int to Test
>> }
>>
>> Bug? or not?
>
> I think this is what I tried to mention in my last responce.

Not quite.. as this works:

enum EnumName { A,B,C };
void foo(EnumName a);
foo(EnumName.A|EnumName.B|EnumName.C);

the problem with the above is the ": ubyte" on the enum.

> The type of
> Test.ONE is Test, but the operator | takes ints, and returns an int, so both
> Test.ONE and Test.TWO are converted to int for the benefit of operator |, and
> the result is syntactically an int. Since ints cannot be implicitly cast to
> named enums, you have a compile error.

It appears something like this is heppening, but something else is also going on when the enum has no base type specified, it seems the 'int' produced by the | _can_ be implicitly cast back to the enum type.

> You make it compile by doing:
>
> #   foo(cast(Test)(Test.ONE|Test.TWO));
>
> I have to say, though, I'm not greatly in favor of using enums as bit masks. I
> realize that (other) people do it all the time, but it seems to me that using an
> enum variable to hold a numerical value for which there is no corresponding enum
> name is violating (my conception of) what an enum is for.  But that's just me,
> and I know other people do things differently.

So how do you define a bunch of flag (off/on) options which you are storing in a ubyte, uint or ulong?

>>> IMO D corrects what can be a very subtle source of bugs
>>> in C/C++ by requiring named enums to be qualified appropriately.  I
>>> would very
>>> much not like this to change, especially if the reason is just to save a
>>> few
>>> keystrokes.
>>
>> The reason above is the first good one I've heard against my proposal. It
>> probably kills it stone dead too.
>
> I've argued that it doesn't, however, /this/ might do:
>
> #    enum A { ONE=1, TWO=2 };
> #    enum B { ONE=2, TWO=1 };
> #    void f(A x);
> #    void f(B x);
> #    f(ONE);
>
> The evaluation of the expression f(ONE) requires an implicit "with", which the
> compiler can only get from the declaration of f() - but this requires knowing in
> advance which overload of f() is going to be used. Unfortunately, overload
> resolution requires knowing the types of the arguments, and so requires the
> arguments to be parsed /first/. We have ourselves some circularity! The only way
> out of this would be to allow "implicit withs" only on non-overloaded functions.
> (Or at least, functions which are not overloaded to the point of ambiguity, but
> we may be asking too much of the compiler at this point).

Yeah, that is nasty, I think in this case and any other where it is ambiguous you simply have to provide the enum ('A' or 'B' in the above example).

Regan

-- 
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
August 17, 2004
In article <opscuuezyz5a2sq9@digitalmars.com>, Regan Heath says...

>> I have to say, though, I'm not greatly in favor of using enums as bit
>> masks. I
>> realize that (other) people do it all the time, but it seems to me that
>> using an
>> enum variable to hold a numerical value for which there is no
>> corresponding enum
>> name is violating (my conception of) what an enum is for.  But that's
>> just me,
>> and I know other people do things differently.
>
>So how do you define a bunch of flag (off/on) options which you are storing in a ubyte, uint or ulong?

Me, personally?

Well, in C and C++, I would do this:

#    struct MyFlags
#    {
#        unsigned int flag1 : 1;
#        unsigned int flag2 : 1;
#        unsigned int flag3 : 1;
#        unsigned int flag4 : 1;
#    };
#
#    struct MyFlags myFlags;
#    myFlags.flag2 = 1;
#    if (myflags.flag3) ...

But of course you can't do that in D. In other langauges, I might do something like:

#    const uint FLAG1 = 0x01;
#    const uint FLAG2 = 0x02;
#    const uint FLAG3 = 0x04;
#    const uint FLAG4 = 0x08;
#
#    int myFlags;
#    myFlags |= FLAG2;
#    if ((myFlags & FLAG3) != 0) ...

although of course the code is then less typesafe. More likely, I'd just do:

#    bool flag1;
#    bool flag2;
#    bool flag3;
#    bool flag4;
#
#    flag2 = true;
#    if (flag3) ...

(although that, of course, is not bit-packed).

In D, however, there is a brand new option, to replace C's struct bitfields, which is this:

#    enum { FLAG1, FLAG2, FLAG3, FLAG4, NUM_FLAGS };
#    bit[NUM_FLAGS] myFlags;
#
#    myFlags[FLAG2] = true;
#    if (myFlags[FLAG3]) ...

I've just started playing with this idea. I have no idea how efficient it is/isn't.

Jill


August 17, 2004
On Tue, 17 Aug 2004 06:55:26 +0000 (UTC), Arcane Jill <Arcane_member@pathlink.com> wrote:
> In D, however, there is a brand new option, to replace C's struct bitfields,
> which is this:
>
> #    enum { FLAG1, FLAG2, FLAG3, FLAG4, NUM_FLAGS };
> #    bit[NUM_FLAGS] myFlags;
> #
> #    myFlags[FLAG2] = true;
> #    if (myFlags[FLAG3]) ...
>
> I've just started playing with this idea. I have no idea how efficient it
> is/isn't.

But of course! I simply wasn't thinking in D!

Regan

-- 
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
August 18, 2004
antiAlias schrieb:

> If you perhaps had a sense of joviality you would already know. Or, if you'd
> bother to look at prior posts, you would already know. My name is Kris, and,
> if you'll graciously concede to it, I'll post under whatever "alias" suits;
> just as others do.

I did take a short glance at them, but perhaps i missed the core. It is beyond my possibility to read everything on this newsgroup. And isn't it a bit arrogant of you to think that everyone should recognize you from one word? And though i do change my nicks from time to time, i have always posted under my real name.

> That aside, I'm certainly entitled to my opinion. Just as you, apparently,
> are entitled to your rather staunch opinion over a variety of matters.

I don't have a strong opinion on most matters, but i tend to support Walter unless i have been convinced otherwise. And i'm easy to convince.

> Further; if you had any sense of etiquette, you'd understand that it's
> considered rather 'uncool' to jostle individuals over their identity in a
> public forum. Or perhaps you were being pompously arrogant instead.

Yes, i am arrogant. But i'm nontheless sorry if this appeared hostile to you.

But look at it from my point of view. If i had recognized that it comes from you, it would be totally different, because i have read a number of posts from you, which make me think you are a smart person. And though i may be not always of the same opinion as you, i have come to respect your opinion because it has ground, and it's explained well, and you have a major influence on my opinion.

But the only thing i saw was someone i don't know just shouting out "BULLSHIT" without any explaination. So i just wanted to have that cleared up, whether the person has a reeason to say so. Under a certain kind of mood, i could have written a much more harsh message than i did if i had time.

-eye
August 18, 2004
Arcane Jill schrieb:

> I agree with this, and I'd just like to remind everyone that the big W himself
> (in post http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/3072) said:
> "in general I'd like to request that we leave it up to the person using a handle
> to reveal themselves or not as their choice".

Speaking of etiquette and such, it is usual that a person introduces himself or herself before speaking up. It is up to the person to share or not any personal data, but some piece of relevant information such as "I am new to D" or "I have been using D for a while" or "I have some experience in this other language" or "I have worked in this-or-that field of interest" or somesuch is in fact necessary for successful communication.

-eye
August 19, 2004
"Ilya Minkov" <minkov@cs.tum.edu> wrote ..
>
> beyond my possibility to read everything on this newsgroup. And isn't it a bit arrogant of you to think that everyone should recognize you from one word?

Now there's a 'spin' if ever I saw one. I'll do you a favour Ilya: http://thesaurus.reference.com/search?q=pseudonym%20 . See those references to "alias", "incognito", "anonym" ...


> But look at it from my point of view. If i had recognized that it comes from you, it would be totally different,

Ahh ... shallowness in its very finest guise.


> cleared up, whether the person has a reeason to say so. Under a certain kind of mood, i could have written a much more harsh message than i did if i had time.

Thrilled to hear you're such a truly thoughtful, warm, and charming individual.



August 19, 2004
antiAlias schrieb:

> Now there's a 'spin' if ever I saw one. I'll do you a favour Ilya:
> http://thesaurus.reference.com/search?q=pseudonym%20 . See those references
> to "alias", "incognito", "anonym" ...

Should that add any value to the empty message of yours?

> Ahh ... shallowness in its very finest guise.

Pfft. And you are perfect and everyone should be like you. Omniscient amd omnipotent.

> Thrilled to hear you're such a truly thoughtful, warm, and charming
> individual.

Hrrr. Hr Hr Hr. :>>>>>>

-eye
August 19, 2004
Guys, guys. Please desist.

It pains me to see two smart chaps, both of whom I respect, in a slagging match.

Now if one of you were an idiot, I'd cheer insanely as I watched the unfair crushing of the Christian in the lion's jaws.

Simon the Softie

"Ilya Minkov" <minkov@cs.tum.edu> wrote in message news:cg20pb$1qn9$1@digitaldaemon.com...
> antiAlias schrieb:
>
> > Now there's a 'spin' if ever I saw one. I'll do you a favour Ilya: http://thesaurus.reference.com/search?q=pseudonym%20 . See those references to "alias", "incognito", "anonym" ...
>
> Should that add any value to the empty message of yours?
>
> > Ahh ... shallowness in its very finest guise.
>
> Pfft. And you are perfect and everyone should be like you. Omniscient amd omnipotent.
>
> > Thrilled to hear you're such a truly thoughtful, warm, and charming individual.
>
> Hrrr. Hr Hr Hr. :>>>>>>
>
> -eye