This file contains thoughts, ideas and hopefully a format for Project Argonauts.
- It should wrap around existing data as much as possible
- Strictly declarative; nothing that "runs"
- Type system with simple templates
- Instantiation is done by the argonauts compiler before generating code
- Comments
- C-like syntax
// ...
and/* ... */
for comments- Statements end with
;
- Blocks with
{
and}
- Built-in types
- Need to be supported by all languages
- 8/16/32/64bit signed/unsigned integers
Double
,String
,Boolean
,List<Type>
,Map<Key, Value>
,Binary
?Value
: can be anything
- Custom definable types
- Enum: Contains a set of entries
- Struct: Contains a set of members (name -> type)
- Variant: Can be different things
- Aliases
- Some way to describe extra data (for both structs, enums, members, aliases, enum entries etc. etc.)
- Examples:
- Documentation data (human readable name, description, examples)
- Validation data (constraints)
- Extra layout information (indexes, other information that allows optimizations)
- Java-style annotations? (
@Annotation(...args...)
- Doxygen-style comments for documentation stuff?
- Something else?
- Examples:
// unless overriden, places using the OrganizationType type will have Commercial as the default
@Default(OrganizationType::Commercial)
enum OrganizationType<UInt8> {
// the numbers are for tighter packing
@Doc(title="Commercial Organization", description="Says that this is a **commercial** organization")
Commercial = 0;
Voluntary = 1;
Governmental = 3;
}
struct Person {
@Validate.MinLength(3)
/* attribute name comes before type (easier to read) */
name String;
salary UInt32;
@Validate.Pattern(/((Senior|Junior) .*)|(Chief [^ ]* Officer)/)
title String;
}
struct HelicopterOwner {
model String;
}
// a Manager is BOTH a person and a helicopter owner
struct Manager : Person, HelicopterOwner {
/* each string needs to be at least 3 characters */
@Validate.Value.MinLength(3)
subordinates List<String>;
}
// an Employee is EITHER a person or a manager
@TypeColumn("type")
variant Employee : Person, Manager;
alias Department : Map<String, List<Employee>>;
@Doc(description="Describes an organization")
struct Organization {
type OrganizationType;
@Validate.Value.MinSize(1)
departments Map<String, List<Employee>>;
}