C# and typedef

Started by
130 comments, last by TangentZ 19 years, 11 months ago
with typedef you declare a (compile time-) variable that holds a type.

there is no vardef for the variables (just because you have to specify a type..).
other languages do have that..
var in visual basic, i believe..

as this, you pass them around in metaprogramming as you pass around normal variables in your normal code..

oh, and.. BillPo. you can have your opinion. but if you follow it the way you do in this topic, you soon get a yellow addon to your nick.

watch your mouth, dude.



If that''s not the help you''re after then you''re going to have to explain the problem better than what you have. - joanusdmentia

davepermen.net
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

My Page davepermen.net | My Music on Bandcamp and on Soundcloud

Advertisement
Seriously, as someone suggested, can''t "using" solve your problem?
Well, not quite.

I mean, sure, I can put a "using MyType = System.In32;" or
whatever, at the top of *EVERY* file. Then use "MyType"
throughout.

I think that''s the closest I can get in C#. It''s still not
"one definition", but oh well.

A change still means opening every file invovled.


Kami no Itte ga ore ni zettai naru!
神はサイコロを振らない!
The only possible advantage I could ever see to using a typedef in C# would be to rename float or double to be Real. Or to rename int or long to be Integer for the purpose of compiling with a percision of your choosing. But even that I see as being limited in usefulness because you should carefully choose your persicion ahead of time and plan for changes.

-SniperBoB-
quote:Original post by tangentz
Well, not quite.

I mean, sure, I can put a "using MyType = System.In32;" or
whatever, at the top of *EVERY* file. Then use "MyType"
throughout.

I think that''s the closest I can get in C#. It''s still not
"one definition", but oh well.

A change still means opening every file invovled.


Kami no Itte ga ore ni zettai naru!


Yes, but if you''re working with an IDE you should now be able to do a replace in files since you''ve got an unique name - as far as your effort goes, that''s pretty minimalistic - I''m not saying it''s perfect, just that it''s fairly simple to do.
quote:Original post by alexmoura
Yes, but if you''re working with an IDE you should now be able to do a replace in files since you''ve got an unique name - as far as your effort goes, that''s pretty minimalistic - I''m not saying it''s perfect, just that it''s fairly simple to do.
That''s not safe either. There could be MyVar and Blaa.Bloo.MyVar, and both MyVar''s would be replaced. Or some other file could have MyVar which means something else, and should stay as MyVar and not be replaced. Or one could have a method name called MyVar. These may sound like pretty uncommon things but they would happen in a big project if one just relied on blind search and replace.

Right. I''d never do a blind global-file-search-and-replace
in a (moderate-sized) project, mixed with code written by
someone else. It''s very risky. My paranoid self would
not allow such a thing, so I''d end up combing through each
and every file, anyway. It''s a lot of unnecessary work in
the absence of typedef.


Kami no Itte ga ore ni zettai naru!
神はサイコロを振らない!
lol I was going to post a reply, and explain how languages are different and that you have to look at the design aspect and certain issues before being critical. Then I realized it would be pointless because the majority of people are here to throw around "c++ 4 teh win!".

I mean one of the biggest problems is the fact that people try to write C++ code in C#. Why don't you try doing that in Scheme? LISP? VB? Java? .. you don't, because someone has told you that if you can program in C++ you know C#.

Really it is almost opposite, because C# is all about design and writing your application instead of "writing for" your application. The languages are similar but you should not be writing C++ code using the C# language at all.


I would get into the typedef argument and how typedef is flawed, bad design, etc.. but the fact is that this thread is already full of invalid information, and basically a bunch of C++ programmers pretending they are Hulk Hogan and flexing the muscles over others.

daveperman and dmikesell are the only people on this thread that I know ACTUALLY have experience using C++ that are bashing C#. The majority of this thread are 16 year olds with an ego that love to bash others. I am unsure why dmikesell has got into this "C# bashing" laughing about no typedefs, etc.. because usually you have some great points and debates, but this time you only look like a rabid fanboy. You have been coding for a long time, you should know that all languages are designed different.

I have been programming professionally with C++ LONGER than anybody on this thread with the exception of maybe the 2 I listed above (maybe Arlid as well, I'm not sure of his background). So please don't try to tell me why C++ is better than C# because I've used C++ forever and recently in the last couple years switched to C# professionally at work.

[edited by - Imperil on January 14, 2004 9:51:37 AM]
Like a few people have already stated :-) C# doesn''t have typedef''s. I think generic''s in C# 2.0 should solve the problem though or atleast a better solution.
quote:Original post by Imperil
that love to bash others. I am unsure why dmikesell has got into this "C# bashing" laughing about no typedefs, etc.. because usually you have some great points and debates, but this time you only look like a rabid fanboy. [edited by - Imperil on January 14, 2004 9:51:37 AM]


What bashing comments did I make in this thread? The straight-jacket one? I honestly feel that way when programming in Java (e.g. one way to do everything, whether you like it or not).

I resent the "rabid fanboy" reference. I''m a rabid fanMAN! ;-)



--
Dave Mikesell Software & Consulting

$ rm * .o
.o: No such file or directory
$ ls
$ ls
$ ls

This topic is closed to new replies.

Advertisement