Talk:Define a primitive data type: Difference between revisions

Attempt to clarify task intention
(second look told me the real issue with java is not there)
(Attempt to clarify task intention)
Line 4:
 
:: After posting my Fortran code, I've got another look at Java, and discovered that the only Java code issue is not the fact that it "uses" a class: it does the same the C++ code, with the difference that C++ allows operator overloading, Java does not. The real issue with Java is that it really does not accomplish the task... (2+2¢ makes 4, day by day we can become reach:D) --[[User:ShinTakezou|ShinTakezou]] 18:13, 1 March 2009 (UTC)
 
All the Java documentation I have read separates primitive types (int, char, float) from all other Java types. In Java the primitive types do not inherit from the Class class. They can only be passed by value to a function, while all classes are passed by reference. Java provides wrapper classes for the primitive types to bridge the gap between the primitive types and everything else in Java. These wrapper classes allow the programmer to use the primitive types with container classes. For instance, one cannot create a vector of int. One must create a vector of the Integer wrapper class. I was not looking exactly for "built-in scalar types". Some languages allow the definition of scalar types which are not built-in. Ada is one such language. Ada allows the programmer to define a wide variety of scalar types, none of which are built-into the language. For instance, it is possible to define a modular integer type with a range of values from 0 through 9. That user-defined type can be used as an actual generic parameter whenever a discrete scalar type is specified as the type of the formal generic parameter. Ada tagged types, which support inheritance, cannot be used as an actual generic parameter when a discrete scalar type is specified as the type of the formal generic parameter.
 
The task is intended to identify how such primitive data types are defined in your language of choice. If the language does not support the definition of user-defined primitive types, then the language cannot support the task. This task is intended to be different than a task to define a class. --[[User:Waldorf|Waldorf]] 03:35, 2 March 2009 (UTC)
Anonymous user