A few notes on choosing between Go and D for a quick project

Almighty Bob via Digitalmars-d digitalmars-d at puremagic.com
Thu Mar 19 17:28:23 PDT 2015


On Thursday, 19 March 2015 at 23:02:07 UTC, w0rp wrote:
>
>>
>> No it doesn't. The private bits are still private, the public 
>> bits are still public.
>>
>> All it does is complicate the user side.
>>
>> Its the emperor's new clothes.
>
> It's not possible to construct a voldemort type outside of the 
> function where it was declared, and you can't know what that 
> type is, just what the API is. You can force type deduction so 
> the type returned can be changed without breaking code, so long 
> as the API is the same. That's how it increases encapsulation.

Ok I can see the benefit of having a return type that can only be 
constructed by the function returning it. ***In some cases***

But being able to change the return type doesnt actualy increase 
encapsulation. you still have to return something with the same 
public API. Only now you have ***less*** guarantees over what 
your getting than you did before. Could be an array could be a 
linked list. Who knows?

Maybe I'm a bit long in the tooth but for something like 
cvsReader I want an array of records, there's isnt anything else 
that would ever make any sense. So the idea that I now how to 
jump through hoops to keep hold of whatever that function 
returns, just in case some divvy might want change what kind of 
structure it returns one day, is frankly absurd.




More information about the Digitalmars-d mailing list