On Wed, Aug 28, 2013 at 12:08 PM, Jonathan S. Shapiro <[email protected]>wrote:

> On Wed, Aug 28, 2013 at 3:39 AM, Bennie Kloosteman <[email protected]>wrote:
>
>> +1 for typed typedefs .. too many ints in C it would be very usefull
>>  even in business apps to have say typedef int CustomerKey ;  will stop a
>> lot of bugs when you use the wrong foreign key in CRUD code.
>>
>
> From a language design perspective, typedefs are an interesting issue. The
> question is: does a typedef introduce a new, distinct type? If so, then
> we're really talking about NewType, and all of the operators on the
> underlying type do not work on the new type (unless suitably extended). The
> type rules for that extension aren't always simple.
>

>From your comments I can see some of why they omitted it.

The cases I'm thinking of involve defining a new distinct type.. because I
specifically want to prevent any implicit casts or operations on it. (Such
as a "user-id" which happens to be an int, but for which increment a really
bad thing to do)

That said, these cases are handled easily enough by making a "struct UserID
{ int _id; }" which hides the details and AFAIK is just as efficient as
passing around the original int.
_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev

Reply via email to