February 22, 2014 Re: [Fwd: Re: [go-nuts] Re: Generics false dichotomy] | ||||
---|---|---|---|---|
| ||||
Posted in reply to deadalnix | On Saturday, 22 February 2014 at 01:39:28 UTC, deadalnix wrote: > On Saturday, 22 February 2014 at 01:36:48 UTC, Walter Bright wrote: >> On 2/21/2014 5:27 PM, deadalnix wrote: >>> That makes me sad that D has Java's object model rather than let's say, scala's >>> (which work with traits/interfaces). >> >> D's object model works with interfaces. > > I'm talking about this: > http://joelabrahamsson.com/learning-scala-part-seven-traits/ https://gist.github.com/JesseKPhillips/9147869 Two notes, Creating an array required casting the first item to the common type. D doesn't let you creating a new object and implement an interface. It seems that std.typecons is getting tripped up on the final method fly() so it can't be used either. |
February 22, 2014 Re: [Fwd: Re: [go-nuts] Re: Generics false dichotomy] | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jesse Phillips | On Saturday, 22 February 2014 at 02:52:37 UTC, Jesse Phillips wrote: > On Saturday, 22 February 2014 at 01:39:28 UTC, deadalnix wrote: >> On Saturday, 22 February 2014 at 01:36:48 UTC, Walter Bright wrote: >>> On 2/21/2014 5:27 PM, deadalnix wrote: >>>> That makes me sad that D has Java's object model rather than let's say, scala's >>>> (which work with traits/interfaces). >>> >>> D's object model works with interfaces. >> >> I'm talking about this: >> http://joelabrahamsson.com/learning-scala-part-seven-traits/ > > https://gist.github.com/JesseKPhillips/9147869 > > Two notes, > > Creating an array required casting the first item to the common type. > > D doesn't let you creating a new object and implement an interface. It seems that std.typecons is getting tripped up on the final method fly() so it can't be used either. This code works fine: http://dpaste.dzfl.pl/c0b3a941d917 |
February 22, 2014 Re: [Fwd: Re: [go-nuts] Re: Generics false dichotomy] | ||||
---|---|---|---|---|
| ||||
Posted in reply to Meta | On Saturday, 22 February 2014 at 03:03:18 UTC, Meta wrote:
> This code works fine:
> http://dpaste.dzfl.pl/c0b3a941d917
That is an anonymous class, that is defining and instantiating the class, which isn't what the scala code was doing. (BTW this feature was added because Java could do it).
|
February 22, 2014 Re: [Fwd: Re: [go-nuts] Re: Generics false dichotomy] | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jesse Phillips | On Saturday, 22 February 2014 at 03:41:29 UTC, Jesse Phillips wrote:
> On Saturday, 22 February 2014 at 03:03:18 UTC, Meta wrote:
>> This code works fine:
>> http://dpaste.dzfl.pl/c0b3a941d917
>
> That is an anonymous class, that is defining and instantiating the class, which isn't what the scala code was doing. (BTW this feature was added because Java could do it).
Sorry, I thought you meant it doesn't allow you to create a new object that implements a certain interface, instead of creating a new object and then implement an interface. Looking at the Scala example again, I see it is indeed different.
|
February 23, 2014 Re: [Fwd: Re: [go-nuts] Re: Generics false dichotomy] | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paulo Pinto | On Monday, 17 February 2014 at 06:32:19 UTC, Paulo Pinto wrote:
>
> Well, supporting modules would already help. With luck C++ will get them around 2020. I think it won't matter by then.
>
> --
> Paulo
Someone said that 10 years ago. Whether it's true 5 years from
now entirely depends on the state of the alternatives by then,
not on the state of C++. Don't underestimate the resistance to
change.
|
February 23, 2014 Re: [Fwd: Re: [go-nuts] Re: Generics false dichotomy] | ||||
---|---|---|---|---|
| ||||
Posted in reply to SomeDude | Am 23.02.2014 05:00, schrieb SomeDude:
> On Monday, 17 February 2014 at 06:32:19 UTC, Paulo Pinto wrote:
>>
>> Well, supporting modules would already help. With luck C++ will get
>> them around 2020. I think it won't matter by then.
>>
>> --
>> Paulo
>
> Someone said that 10 years ago. Whether it's true 5 years from
> now entirely depends on the state of the alternatives by then,
> not on the state of C++. Don't underestimate the resistance to
> change.
Sure, it is always a matter if OS vendors would invest in another systems language or not.
|
February 23, 2014 Re: [Fwd: Re: [go-nuts] Re: Generics false dichotomy] | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On 2014-02-16 22:05:10 +0000, Walter Bright said:
> "However, I agree that there may well be other reasons to not have them in Go, such as their simply not being especially useful in day-to-day programming; but I don't have enough experience with meta-programming to make such a judgment."
>
> Some years ago, I felt exactly the same way about generics. I have recently written some very interesting D programs, and I would have shocked my former self with nearly every function being a template.
I could second this. When you have a strong type system as in D, it makes sense to have strong meta-programming to avoid rework. My current project reflects on all modules to look for classes which inherit from a particular base class -- and then wires those up for fast serialization and deserialization. This would be impossible to do at compile time in any other language, and impossible in most languages, and requiring slow run-time reflection in others.
I've found a use for something similar to this in most projects I've done lately. In C# I use Linq Expressions to compile anonymous delegates at runtime to do something similar -- but the code is a nightmare.
-S
|
Copyright © 1999-2021 by the D Language Foundation