Repository navigation
docs: compile with mago compile, add Iterable and Object, make output a call - #21
Merged
Merged
Conversation
… a call
Typed compilation was approved without saying how code gets compiled and
run. A lazy plain PHP source such as a query cursor had no PHP# type, nor
did any object. And PHP's echo, print and die stayed outside the effect
system, with die("…") reporting success while it prints a failure.
Compile and run PHP# with mago compile:
- vendor/bin/mago compile writes each accepted .sharp file as a .sharpc
file in one .sharp/ folder at the project root, vendor included
- The engine runs only current compiled files, and refuses a missing,
stale or mismatched one with a message that names the fix
- In development, sharp.compile_command compiles a stale file on demand
- A type error or a broken structure rule stops the file from running
- Rejected: each file compiles alone, and the engine receiving the types
beside the source
Read anything a loop can read with Iterable<T>:
- List, Set and a Map's values are Iterable<T>, compiled to PHP's iterable
- filter, map and take are lazy, and run only when toList() or a loop
reads them
- A lazy plain PHP source is checked element by element as it is read
- Rejected: an Iterable that only a loop reads
Hold any object with Object:
- Object compiles to PHP's object, and Object? adds null
- It has no members until is narrows it, and passes where Any is expected
- Rejected: Swift's AnyObject
Print and exit with function calls:
- echo and print are compile errors that name printf or fwrite
- die is a compile error: write the message to STDERR, then exit(1)
- exit(code) stays, skips finally blocks, and is not pure
- Rejected: PHP's forms as they are
docs/
├── spec.md <- sections 8, 12, 17, 24, 27, 28 and 29
└── decisions/
├── 029-typed-compilation.md <- records mago compile and .sharp/
├── 033-iterable.md <- added, records lazy Iterable<T>
├── 034-output-and-exit.md <- added, records output as calls
└── 035-object.md <- added, records Object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
docs: compile with mago compile, add Iterable and Object, make output a call
Typed compilation was approved without saying how code gets compiled and
run. A lazy plain PHP source such as a query cursor had no PHP# type, nor
did any object. And PHP's echo, print and die stayed outside the effect
system, with die("…") reporting success while it prints a failure.
Compile and run PHP# with mago compile:
file in one .sharp/ folder at the project root, vendor included
stale or mismatched one with a message that names the fix
beside the source
Read anything a loop can read with Iterable:
reads them
Hold any object with Object:
Print and exit with function calls:
docs/
├── spec.md <- sections 8, 12, 17, 24, 27, 28 and 29
└── decisions/
├── 029-typed-compilation.md <- records mago compile and .sharp/
├── 033-iterable.md <- added, records lazy Iterable
├── 034-output-and-exit.md <- added, records output as calls
└── 035-object.md <- added, records Object