[bitc-dev] FN keyword
Jonathan S. Shapiro
shap at eros-os.org
Thu Aug 12 09:49:54 PDT 2010
On Thu, Aug 12, 2010 at 8:20 AM, Ben Kloosterman <bklooste at gmail.com> wrote:
> > That's one issue. Another issue is that attributes can't be inferred,
> because the compiler does not (in general) know anything about their
> semantics.
>
>
>
> Not sure what you mean In C# they are just a normal assembly types that
> inherit from System.Attribute that can be read from CIL , the properties
> are used for additional semantics so the runtime defines the attributes
> semantics which the compiler knows about. This either requires the
> compiler ( and IDE for auto completion) to read metadata or the IR/CIL of
> the attribute lib.. No insignificant task but you get significant benefits.
>
That's a different issue. What I'm saying is that if attribute [a] is
attached to some type T, the compiler has no idea how/where to propagate [a]
to other types. There is no inference.
> >But worse than this: when attributes are used to encode type, we need a
> way to attach them to types and print them accordingly. In C#, an attribute
> cannot be introduced at a type, only at a type definition. The way you work
> around this is by introducing and using a typedef. The associated
> information is lost for pretty-printing purposes, exactly because it *
> isn't* a type.
>
>
>
> You could put the Attribute at the type variable ( if static) but C#
> doesn’t use this , such a construction (though possible) would be ugly and
> need some horrible parser interaction. Im pretty sure in C# it just uses the
> square brackets and passes that on to the compiler who decides if it is
> valid after looking it up via reflection. (And the auto completion helps
> create it).
>
C# can't do it at all. C# does not allow annotation on types, only on type
definitions. You can't even do attributes on local variables without various
kludges - and those aren't understood across languages.
> Am I right in BitC you cant have functions in structures only objects (
> so c instead of C++) ?
>
BitC structs can have both functions and methods.
shap
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.coyotos.org/pipermail/bitc-dev/attachments/20100812/97feee7e/attachment.html
More information about the bitc-dev
mailing list