Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[hay] Don't mutate globals in Hay evaluation
This goes for both 'hay eval :result { }' and eval_hay(). Add example of how to annotate commands / procs with top-level hay nodes. Still need to figure out how to serialize both hay nodes and procs. Procs probably need signatures too.
- Loading branch information
Andy C
committed
Jun 11, 2022
1 parent
f9193a5
commit d7c4068
Showing
7 changed files
with
124 additions
and
64 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# A way that programs could annotate procs and external commands | ||
|
||
hay define Sig | ||
|
||
Sig grep { | ||
pure = true | ||
} | ||
|
||
Sig foo { | ||
pure = false | ||
} | ||
|
||
proc foo { | ||
echo 'where is my sig?' | ||
} | ||
|
||
case ${1:-} { | ||
|
||
# Is this a good pattern? | ||
# You have to run it twice, which is not great. | ||
|
||
(''|sigs) | ||
json write (_hay()) | ||
;; | ||
|
||
('procs') | ||
pp proc | ||
;; | ||
|
||
# TODO: would be nice to validate this | ||
(*) | ||
@ARGV | ||
;; | ||
} | ||
|