Walter Banks said:
Keith said:
Keith Thompson wrote:
[...]
Jacob has implemented user defined data types in his compiler maybe
someone who has used this feature can weigh in with their experience.
I didn't know that. I'd be interested in seeing some documentation
on this feature.
Look for operator overloading and jacob navia
The following (one of many links) has an overview of Jacob's ideas
http://bytes.com/topic/c/answers/212416-operator-overloading-c
That appears to be an unacknowledged copy of a discussion thread
from this newsgroup.
It is syntactically simple BUT the devil is always in the details as
we found out. Even a simple type can have complex implementation
issues that affect application reliability. As well as operators
new data types need casts and other conversion code to be complete.
As far as I can see from the discussion, the extension enables
operator overloading but I don't see anything specific about a
new mechanism for creating new types. It seems to provide a way
to treat types created by existing mechanisms *as if* they were
numeric types, e.g., by applying arithmetic operators to them.
There are two things that need to be done in creating user defined
types. A data type needs to be created through some mechanism and
operators need to be defined. If I read what Jacob has written on
this a new data structure type can be defined with a typedef and
then manipulated with user defined operators. This is a significant
departure from using typedefs by themselves which are restricted
to using C operators defined by the compiler.
I haven't tried jacob's implementation or read the documentation, so the
following is speculative.
My guess is that, for example, you can write:
typedef struct { int value; } my_int;
my_int operator+(my_int x, my_int y);
but that's just because "my_int" is an alias for the struct type, which
is itself a new type. This could have been written as:
struct my_int { int value; };
struct my_int operator+(struct my_int x, struct my_int y);
typedef struct my_int my_int;
But you can't write:
typedef int my_int;
my_int operator+(my_int x, my_int y);
because the latter is identical to:
int operator+(int x, int y);
In other words, I'm guessing that this extension really has nothing
to do with typedefs. Overloaded operators are syntactic sugar
for things that could have been defined as ordinary functions.
(Note that I didn't write "*just* syntactic sugar"; I'm not
commenting on the merits of the idea.)
Perhaps jacob will jump in and confirm or deny this.