Implicit type conversion: Difference between revisions

Added Wren
(Added Delphi documentation for Implicit type conversion)
(Added Wren)
Line 1,392:
 
Defining a new type requires writing an extension to Tcl in [[C]] (or whatever the host programming language is, so [[Java]] for [[JTcl]]); the interfaces for doing this are not directly exposed to the Tcl script level because they require direct memory access, which Tcl normally does not permit in order to promote overall process stability.
 
=={{header|Wren}}==
{{libheader|Wren-big}}
As far as the built-in types are concerned, Wren does not really have any implicit conversions.
 
There is only one built-in numeric type, Num, which represents a double precision floating point number. When using the 'bit' operators, Num values are converted internally to 32 bit unsigned integers though this type is not actually exposed to the user who only knows about it from its effects.
 
In conditional expressions, 'null' acts like it is false and any other value acts like it is true but these aren't really implicit conversions to Bool; it's just the way the language works.
 
Also adding implicit conversions to the built-in types is not really as option, as inheriting from these types is not recommended for technical reasons.
 
However, you can define implicit conversions for user defined types. For example, BigInts can be generated from integral Nums or Strings and, when doing operations on BigInts, values of these types are automatically converted to BigInts so the operations can succeed.
<lang ecmascript>import "/big" for BigInt
 
var b1 = BigInt.new(32)
var b2 = BigInt.new ("64")
 
var b3 = b1 + b2 + 2 + "2"
System.print(b3) // 100</lang>
 
=={{header|zkl}}==
9,476

edits