Most of the features in this document requires to include '/pliant/language/compiler.pli' module.
The '<-' parameter is optinal and provides initialization value for the fields.
When a new type is created, Pliant shall reverse fields ordering and insert padding bytes to optimize fields alignment. If this is not expected because the type is used by another C program as an example, you can use 'packed' instruction to desable any initiative on Pliant side.
Just as for functions, it should be possible to use 'later' to escape from a circular reference between types, also I just could not find an example at document writing time.
One key point of Pliant syntax is to enable no difference at syntax level between a field and a method. This is very important, because in a real software life cycle, a field becoming a method is a classical event, so avoiding to have to change all applications using it is a serious bonus.
Here is a sample:
In this example, we see that 'size' method is used exactly the same way as if it was a real field.
method v 'size :=' i
Through defining 'size :=' method, we turn 'size' to a full virtual field that can also be assigned a new value.
function foo i
You can get the type of any data using 'typeof' keyword:
var Pointer:Type t :> typeof 3
Looks simple, but be warned that it's not so:
Here are two sample to illustrate this:
var Pointer:Int a
will print 'Int', not '(Pointer Int)'
will print 'ImagePrototype', not 'ImagePixmap'.
In the previous sample, if you want to get 'ImagePixmap', just do:
console (entry_type addressof:p):name eol
Most Pliant data types are defined in /pliant/language/type/ part of the source tree.