January 15, 2004 Re: M$ stupidity (was Re: suggestion for cast expression) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert M. Münch | >
> Same for German, that's the most stupid thing I have ever seen. It would be OK if the english version would work in a shadow way... but hey, it's MS the 50% company.
>
what about Polish, where INSTR is replaced with FRAGMENT.TEKSTU? :-)
|
January 15, 2004 Re: suggestion for cast expression | ||||
---|---|---|---|---|
| ||||
Posted in reply to The Lone Haranguer | >You've reminded me of when I took a trip to Germany in 1997, I tried to send an email from an Internet cafe -- I couldn't find an "at sign" (@) on the keyboard, finally I pasted one from some website.
For the feature: It's the same key as Q, but you hvae to hold Alt Gr while pressing it. Using Alt Gr you can access even more symbols. Alt Gr+M = µ, Alt Gr+< = | ...
|
January 15, 2004 Re: suggestion for cast expression | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean L. Palmer | I don't like both versions. What about a simpler notation easy to learn for newbees? Somthing like this: Foo foo = bar as Foo; (This would be the same as Foo foo = cast(Foo)bar; ) |
January 15, 2004 Re: suggestion for cast expression | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthias Becker | In article <bu67e4$27q7$1@digitaldaemon.com>, Matthias Becker says... > >I don't like both versions. What about a simpler notation easy to learn for newbees? Somthing like this: > >Foo foo = bar as Foo; > > >(This would be the same as >Foo foo = cast(Foo)bar; >) what don't you like (can't get previous message)? did you see the Foo foo = bar.castTo(Foo) or suggestion? This would be the same as... well is so obvious that I don't have to explain it. Ant |
January 15, 2004 Re: suggestion for cast expression | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthias Becker | Matthias Becker wrote:
> I don't like both versions. What about a simpler notation easy to learn for
> newbees? Somthing like this:
>
> Foo foo = bar as Foo;
>
>
> (This would be the same as
> Foo foo = cast(Foo)bar;
> )
>
>
two ways of doing something is the most confusing thing for newbs (speaking from experience), especially when looking at other source code, Make one good way an keep that, is the best thing in my opinion.
Regards
Lewis
|
January 15, 2004 Re: suggestion for cast expression | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lewis | In article <bu697k$2aqj$1@digitaldaemon.com>, Lewis says... > >Matthias Becker wrote: > >> I don't like both versions. What about a simpler notation easy to learn for newbees? Somthing like this: >> >> Foo foo = bar as Foo; >> >> >> (This would be the same as >> Foo foo = cast(Foo)bar; >> ) >> >> > >two ways of doing something is the most confusing thing for newbs (speaking from >experience), especially when looking at other source code, Make one good way an >keep that, is the best thing in my opinion. >Regards >Lewis So let's kick of the old notaion. D still hasn't reached version 1.0, so it's possible to change the language rather than just extending it. About the notation Foo foo = bar.cast_to(Foo); In C++ you'd do it like this: class Bar { public: template <typename T> T cast_to () { return static_cast<T>(*this); } }; But as D doesn't support non-static member-templates this isn't possible. As said: C++ is more powerfull than D. I hope this will change till version 1.0, as many aspects of D are realy cool. |
January 15, 2004 Re: suggestion for cast expression | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthias Becker | In article <bu6bd0$2efj$1@digitaldaemon.com>, Matthias Becker says... > >So let's kick of the old notaion. It's a must ;) > >About the notation > >Foo foo = bar.cast_to(Foo); Every body knows that "_" is uggly. I see "_" used for low level things only, not any public symbols. This is not a new discussion. Walter noticed this before but I think his last comment was that he didn't see any real advantage. The only advantage I see is readability. if you didn't see the previous discution here it is: the current: (cast(ClassB)(cast(ClassA)getIt()).getOther()).printIt() (i don't even know if it's right) the proposed: getIt().castTo(ClassA).getOther().castTo(ClassB).printIt() for the current version: cast(Foo)bar where the "cast" is optional the advantage is compatibility with older languages. Ant |
January 15, 2004 Re: suggestion for cast expression | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ant | Ant wrote:
> In article <bu6bd0$2efj$1@digitaldaemon.com>, Matthias Becker says...
>
>>So let's kick of the old notaion.
>
>
> It's a must ;)
>
>
>>About the notation
>>
>>Foo foo = bar.cast_to(Foo);
>
>
> Every body knows that "_" is uggly.
>
> I see "_" used for low level things only,
> not any public symbols.
>
> This is not a new discussion.
> Walter noticed this before but I think his last
> comment was that he didn't see any real advantage.
>
> The only advantage I see is readability.
> if you didn't see the previous discution here it is:
>
> the current:
> (cast(ClassB)(cast(ClassA)getIt()).getOther()).printIt()
> (i don't even know if it's right)
> the proposed:
> getIt().castTo(ClassA).getOther().castTo(ClassB).printIt()
>
> for the current version:
> cast(Foo)bar where the "cast" is optional
> the advantage is compatibility with older languages.
>
> Ant
>
>
the proposed: way definetly is the better cleanest way i think
|
January 15, 2004 Re: suggestion for cast expression | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ant | "Ant" <Ant_member@pathlink.com> wrote in message news:bu6dpm$2imd$1@digitaldaemon.com... > In article <bu6bd0$2efj$1@digitaldaemon.com>, Matthias Becker says... > > > >So let's kick of the old notaion. > > It's a must ;) > > > > >About the notation > > > >Foo foo = bar.cast_to(Foo); > > Every body knows that "_" is uggly. > > I see "_" used for low level things only, > not any public symbols. > > This is not a new discussion. > Walter noticed this before but I think his last > comment was that he didn't see any real advantage. > > The only advantage I see is readability. > if you didn't see the previous discution here it is: > > the current: > (cast(ClassB)(cast(ClassA)getIt()).getOther()).printIt() > (i don't even know if it's right) > the proposed: > getIt().castTo(ClassA).getOther().castTo(ClassB).printIt() > > for the current version: > cast(Foo)bar where the "cast" is optional > the advantage is compatibility with older languages. > > Ant > I like the postfix cast, but above code is not realistic IMO... Postfix cast is a quite new syntax for D, so I think that it may not be implemented unless it has a great number of merits or it is easy to be implemented. If member function templates are supported, class A { template castTo(T : A) { T castTo() { return cast(T) this; } } } class B : A { } A b = new B; b.castTo!(B) gives a postfix cast. i.e. postfix casts can be implemented as property templates. So, if property templates are supported, postfix casts may be easy to be implemented. Then it will be time to request the postfix casts to Walter... |
Copyright © 1999-2021 by the D Language Foundation