//! unit bbb
module bbb
{
/*
a test multi line comment block
*/
information /* A test comment */
{
description := "Module // bbb";
version := "1.00";
copyright := "Copyright (C) 2019";
author := "John Ryland"; // author
checksum := "_"; // perhaps compiler can update this or there is a publish step
// perhaps 2 checksums, one for with comments and one without
}
/* another comment */
imports
{
xml,
json@1.00, // perhaps compiler can update here the expected checksum, perhaps with a publish/package build step
reflect@ver, // version is optional, but if added, then perhaps checksums should be added
aaa,
ccc
}
interface
{
//! a strong typedef
type minute := int8 ; // struct minute { int8 value; };
// constants
const flt32 pi := 3.14 ;
//! enum class with generated reflection
enum blah
{
Value1,
Value2,
Value3, // can have trailing comma
}
//! struct with generated reflection
struct bar
{
int16 x;
int16 y;
int16 z;
int32 array[];
}
//! ADT
struct foo; // forward declared
//! docs for function
function makefoo ( ) => foo;
//! docs for function
function makefoo2 ( int8 param ) => foo, bool; // returns a pair
//! docs for function
function makeFooFromString ( string input ) => foo;
//! documentation
//! @param a is input foo
//! @returns new foo
function editfoo ( foo a ) => foo;
}
implementation
{
// perhaps this one doesn't get reflection
// need to think about this. if internal, what case would need reflection?
// this struct is only visible within this implementation so can it have
// any meaning to reflect it? Perhaps there is. Consider makeFooFromString.
// that some how breaks the concept of the interface/implementation divide.
// Perhaps it is part of the interface if it is reflected, so if wanting
// to do something like makeFooFromString, then one must move the foo
// struct to the interface and be explicit that the layout is part of the
// interface and a change to it is a change to the contract.
struct foo
{
int8 x;
int8 y;
int8 z;
}
function makefoo() => foo
{
foo f{ 0, 0, 0 };
return f;
}
function makefoo2( int8 param ) => foo, bool
{
foo f{ 0, 0, 0 };
if ( param < 0 )
{
return ( f , false );
}
return ( f, true );
}
function editfoo(foo a) => foo
{
var a,b := makefoo2(0,1,2,3,4,5,6,7,8,9,10,11,12,13, -201 , 2001 , 0 , -0 );
int8 x := a.x;
int8 y := a.y;
int8 z := a.z;
foo f{ z, y, x };
return f;
}
// comment
function boo(type T, T y) => T // template function
{
T x := 0;
x := 1123 + y;
return x;
}
}
tests
{
function test1()
{
foo f := makefoo();
foo f2 := editfoo(f);
}
}
}