digitalmars.D - stupid cast sintax... why?
- Ant (8/8) Sep 14 2004 look at this:
- kinghajj (4/12) Sep 14 2004 Your way is worse. It makes D look more like a scripting language than a
- Andy Friesen (5/16) Sep 14 2004 Why? The present syntax cannot be confused for anything but a cast, by
- Ant (3/23) Sep 14 2004 because I just had to type that stupid line.
- Vathix (24/24) Sep 14 2004 Just messing around...
- Ant (5/8) Sep 14 2004 ...
- Stewart Gordon (7/17) Sep 15 2004 If it's going to be useful for generic programming, it'll need to be a
- Arcane Jill (7/10) Sep 15 2004 ..and it will segfault/access-violate if object is not some subclass of
look at this: return target.opCmp((cast(ProjectTarget)object).getTarget()); makes no sense... for the new guys - here is how it should be: return target.opCmp(object.castTo(ProjectTarget).getTarget()); this was discussed before and Walter is not interested at all. save your typing for better battles... Ant
Sep 14 2004
In article <pan.2004.09.15.02.26.07.97659 yahoo.ca>, Ant says...look at this: return target.opCmp((cast(ProjectTarget)object).getTarget()); makes no sense... for the new guys - here is how it should be: return target.opCmp(object.castTo(ProjectTarget).getTarget()); this was discussed before and Walter is not interested at all. save your typing for better battles... AntYour way is worse. It makes D look more like a scripting language than a programming language, IMO... I guess as long as I had a choice on which method to use, I'd be OK with it.
Sep 14 2004
Ant wrote:look at this: return target.opCmp((cast(ProjectTarget)object).getTarget()); makes no sense... for the new guys - here is how it should be: return target.opCmp(object.castTo(ProjectTarget).getTarget());Why? The present syntax cannot be confused for anything but a cast, by either a human or a computer.this was discussed before and Walter is not interested at all. save your typing for better battles...So why bring it up? -- andy
Sep 14 2004
On Tue, 14 Sep 2004 21:24:54 -0700, Andy Friesen wrote:Ant wrote:because I just had to type that stupid line. Antlook at this: return target.opCmp((cast(ProjectTarget)object).getTarget()); makes no sense... for the new guys - here is how it should be: return target.opCmp(object.castTo(ProjectTarget).getTarget());Why? The present syntax cannot be confused for anything but a cast, by either a human or a computer.this was discussed before and Walter is not interested at all. save your typing for better battles...So why bring it up? -- andy
Sep 14 2004
Just messing around... template castTo() { template castTo(To) { To castTo() { return cast(To)this; } } } class Foo { mixin castTo; void printName() { printf("Foo\n"); } } class Bar: Foo { void printName() { printf("Bar\n"); } } int main() { Foo f = new Bar; Bar b = f.castTo!(Bar); b.printName(); return 0; }
Sep 14 2004
On Wed, 15 Sep 2004 01:04:57 -0400, Vathix wrote:Just messing around... template castTo()... nice! now we just need to be able to provide our Object class instead of using the predefined. Ant
Sep 14 2004
Ant wrote:On Wed, 15 Sep 2004 01:04:57 -0400, Vathix wrote:If it's going to be useful for generic programming, it'll need to be a defined method of everything, not just Object. Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.Just messing around... template castTo()... nice! now we just need to be able to provide our Object class instead of using the predefined.
Sep 15 2004
In article <pan.2004.09.15.02.26.07.97659 yahoo.ca>, Ant says...look at this: return target.opCmp((cast(ProjectTarget)object).getTarget()); makes no sense.....and it will segfault/access-violate if object is not some subclass of ProjectTarget. May I suggest the code should instead be: or something similar. Arcane Jill
Sep 15 2004