User Tools

Site Tools

Navigation:  Clarion.Net (Clarion#) > Clarion# Language Extensions > Special Data Types >====== Implicitly Typed Local Variables ====== Previous pageReturn to chapter overviewNext page

The Clarion language provides three types of implicit variables:

# a label terminated by a # names an implicit LONG.
$ a label terminated by a $ names an implicit REAL.
a label terminated by a ” names an implicit STRING(32).

Clarion# introduces a 4th:

? a label terminated by a ? names a variable of type “var” (as defined in C#)

An implicitly typed local variable is strongly typed just as if you had declared the type yourself, but the compiler determines the type. The following two declarations of 'v' are functionally equivalent:

v? = 10         !implicitly typed

v  SIGNED(10)   !explicitly typed

An implicit variable defined as variable? instructs the compiler to infer the type of the variable from the expression on the right side of the initialization statement. The inferred type may be a built-in type, an anonymous type, a user-defined type, or a type defined in the .NET Framework class library.

It is important to note variable? does not indicate that the variable? is loosely typed, or late-bound. It just means that the compiler determines and assigns the most appropriate type.

See the “PeopleQuery” shipping sample for an example of this usage.

implicitly_typed_local_variables.htm.txt · Last modified: 2021/04/15 15:57 by