[bitc-dev] Are type classes just abstract, generic classes?
Michal Suchanek
hramrach at centrum.cz
Thu Mar 25 09:13:06 PDT 2010
On 25 March 2010 17:01, Jonathan S. Shapiro <shap at eros-os.org> wrote:
> On Thu, Mar 25, 2010 at 7:20 AM, Michal Suchanek <hramrach at centrum.cz> wrote:
>> Because if you manually write accessors you can include some magic in
>> them or write accessors for non-existent fields to compute/translate
>> them from existing fields. Once you define that something is a field
>> rather than a method you lose all of this.
>
> Not necessarily. Depends on how the compiler implements fields. In
> particular, if the compiler automatically rewrites fields to
> attributes, you haven't lost anything.
>
> OTOH, if you didn't *need* any magic, why add the overhead?
If your compiler automatically converts the two it is pointless to
argue which is better.
However, if you specify a field as data rather than a method returning
the data and the compiler cannot convert the two then you have created
an interface which fails for structs that do have accessors for the
data or don't have the data but can compute it from some other part of
their internal representation.
Thanks
Michal
More information about the bitc-dev
mailing list