Which types are allowed for typed program arguments in EK9?
← Syntax and Structure Rules · Ref: Q947
Program arguments support: String, Integer, Float, Boolean, Character. 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, Date, DateTime, Duration, Millisecond, Colour, Dimension, Money, Path, RegularExpression, Character.
UNSUPPORTED (E07600)
Custom classes, records, traits, enumerations, List, Dict, Optional, or any user-defined type.
WORKAROUND
Use String parameters and parse manually:
MyProgram()
-> configPath as String
// 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: String, custom, E07600, Integer, argument, Boolean, supported, program, Float, type