Re: Non-C bindings in GNOME



Hello,

> But surely any CLR API could only be used from Managed C++ not all of
> C++. I believe that means use of Managed C++ extensions and no use of
> some regular C++ techniques.

There are two issues here.  Let me explain:

.NET defines a subset of interoperable features that work across the
various languages.  This subset is known as the Common Language
Specification.  A subset that was easily adaptable to multiple languages
was chosen for the public APIs.  


There are various levels of CLS compliance:

	CLS consumer:	Can consume objects and definitions from 
		 	other CLS languages.

	CLS producer:	Can produce code which is CLS compliant.

	CLS consumer/producer: Can consume and produce CLS code.

It is important to have a subset, because otherwise you would be forcing
the super set on every programming language.  

Lets take an extreme example to illustrate this: Scheme macros are not
part of the CLS, because that would force every language implementor to
understand these concepts, which might not only be very hard to
implement, but might not make a lot for a user of another language. 
Same applies for example to a C++ template: you would not want to force
every programming language to understand templates and be a producer and
a consumer of them.

So hence, the CLS subset. 

C++ can be a consumer and a producer.  But when you produce code to be
consumed by other languages, you are subject to a number of restrictions
imposed by the CLS specification (the compiler will sometimes report a
warning, and sometimes report an error).  

These restrictions are not only applied to the C++ language, they also
apply to C# itself (the language of choice for the .NET Framework) and
every other CLS producer 

For instance, when producing CLS APIs, you can not use signed bytes
(sbyte) or the unsigned integer versions.  Or expose two public methods
or fields that differ only in case or use underscores in the API.

But for your internal code (or for classes which are not CLS compliant),
you can do anything you feel like doing (C++ templates, C# boxed value
types, Lisp macros, Eiffel/C++ multiple inheritance and what not). 

So you can think of the CLS subset as a contract that various languages
can consume and use (along the lines of a CORBA IDL definition for
example).

So Managed C++ provides the features to expose APIs to .NET and to
consume APIs from .NET.  

Miguel.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]