Make supplier a library type instead of a built-in type #213
Labels
Component: code base
The code quality of the project (does not affect functionality)
Component: DSL
Something that concerns the design of PIE DSL
Priority: low
Status: proposal
Enhancement in the proposal stage
Type: enhancement
New feature or request
Short description
Suppliers can be regular library types, their only special traits are that they are the return value of a task supplier call (
task.supplier(args)
) and that they generate special Java code.Todo list
mb.pie.api.Supplier
the return value of task suppliersSupplier#get
Reason
As a built-in type every part of the language definition needs to be aware of this type. Task suppliers do not require a special built-in supplier type (requires #157). This would remove the supplier type and function from the syntax and static semantics, and possibly a whole bunch of SPT tests for suppliers (we could keep them, although that would require access to the standard library from within SPT tests).
Making the language definition smaller also decreases the amount of special cases users need to remember when learning the language.
Implementation
Definition in the pie standard library:
The compiler can introduce a check in
p2j-ast-call: QCall
that checks the implementation of the type, and if it ismb.pie.api.Supplier
, generate special code:Related issues
Result
is fully supported without the need for special cases in the compiler or language.The text was updated successfully, but these errors were encountered: