Which types are allowed for typed program arguments in EK9?
← Syntax and Structure Rules · Ref: Q947
Program arguments support the built-in types listed below (String, Integer, Float, Boolean, Character and more). NOT custom types.
EK9 programs with typed parameters (style 2) can only use types that the runtime can parse from command-line strings. Custom classes, records, and complex types cannot be automatically parsed.
SUPPORTED TYPES
String, Integer, Float, Boolean, Character, Bits, Date, Time, DateTime, Duration, Millisecond, Colour, Resolution, Dimension, Money and RegEx.
UNSUPPORTED (E07600)
Custom classes, records, traits, enumerations, Dict, Optional, Path, GUID, or any user-defined type. (A List is only accepted as the single List of String parameter of style 1.)
WORKAROUND
Use String parameters and parse manually:
defines program MyProgram() -> configPath as String stdout <- Stdout() stdout.println(`Parse ${configPath} into your custom type`)
See Q889 for program argument styles. See Q888 for program return type.
Example
defines module qa.syntax.programargtypes defines program <?- Program with typed arguments. Only built-in parseable types are allowed. -?> ProgramArgumentTypesDemo() -> name as String age as Integer verbose as Boolean stdout <- Stdout() stdout.println(`Name: ${name}`) stdout.println(`Age: ${age}`) stdout.println(`Verbose: ${verbose}`)
Common mistakes
E07600 — Program arguments are limited to a finite set of parseable built-in types; GUID (like any custom or unsupported type) is rejected with E07600 - use String and parse manually. See ek9 -h E07600 for details.
Incorrect:
name as GUID
Correct:
name as String
Other ways to ask this
- What triggers E07600 PROGRAM_ARGUMENT_TYPE_NOT_SUPPORTED?
- Why can't I use custom types as program arguments?
- What types can a program accept on the command line?
Coming from another language?
Java: main(String[]) only. Python: sys.argv strings. Go: os.Args strings. Rust: std::env::args strings. EK9: compiler-parsed typed parameters from built-in parseable types only.
Keywords: Boolean, argument, Integer, E07600, custom, String, type, Float, program, supported