www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: [OT] What should be in a programming language?

reply Kagamin <spam here.lot> writes:
Yigal Chripun Wrote:

 for instance there's special handling of void return types so it would 
 be easier to work with in generic code. instead of this compiler hack a 
 much simpler solution is to have a unit type and ditch C style void. the 
 bottom type should also exist mainly for completeness and for a few 
 stdlib functions like abort() and exit()

uint and void return types may be nearly equivalent for x86 architecture, CLI makes strong difference between them.
Oct 26 2009
next sibling parent Jason House <jason.james.house gmail.com> writes:
Kagamin Wrote:

 Yigal Chripun Wrote:
 
 for instance there's special handling of void return types so it would 
 be easier to work with in generic code. instead of this compiler hack a 
 much simpler solution is to have a unit type and ditch C style void. the 
 bottom type should also exist mainly for completeness and for a few 
 stdlib functions like abort() and exit()

uint and void return types may be nearly equivalent for x86 architecture, CLI makes strong difference between them.

Are you two talking about the same thing? uint and unit are quite different from each other. My understanding from scala is that most/all uses of unit are optimized away. I still don't know what unit holds...
Oct 26 2009
prev sibling parent Yigal Chripun <yigal100 gmail.com> writes:
On 26/10/2009 14:47, Kagamin wrote:
 Yigal Chripun Wrote:

 for instance there's special handling of void return types so it would
 be easier to work with in generic code. instead of this compiler hack a
 much simpler solution is to have a unit type and ditch C style void. the
 bottom type should also exist mainly for completeness and for a few
 stdlib functions like abort() and exit()

uint and void return types may be nearly equivalent for x86 architecture, CLI makes strong difference between them.

I have no idea what uint has to do with what I said. in type theory, a unit type contains only one value, and a bottom type contains zero values. the single value of unit can be for example an empty tuple. a function like abort doesn't return anything at all so it's return type is the bottom type. In ML all functions have exactly one tuple argument and one tuple return type. so, for example this c function: void foo(); would have the following signature in ML: unit -> unit if we have: void foo(); void bar(); foo(bar()); is perfectly legal with ML semantics since both functions have the signature: unit -> unit
Oct 26 2009