Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new -compact mode, also use for eval when printing function objects #84

Merged
merged 4 commits into from
Aug 1, 2024

Conversation

ldemailly
Copy link
Member

@ldemailly ldemailly commented Aug 1, 2024

$ ./grol -format -compact examples/sample.gr  2> /dev/null; echo
unless=macro(cond,iffalse,iftrue){quote(if !unquote(cond){unquote(iffalse)}else{unquote(iftrue)})}unless(10>5,print("BUG: not greater\n"),print("macro test: greater\n"))fact=func(n){log("called fact ",n)if n<=1{return 1}n*self(n-1)}a=[fact(5),"abc",76-3]m={"key":a,73:29}print("m is:",m,"\n")print("Outputting a smiley: 😀\n")first((m["key"]))
$ ./grol -format -compact examples/sample.gr | ./grol -format -
12:50:10.965 grol dev  go1.22.5 arm64 darwin - welcome!
12:50:10.965 grol dev  go1.22.5 arm64 darwin - welcome!
12:50:10.966 [INF] Formatting stdin
12:50:10.966 [INF] Formatting examples/sample.gr
12:50:10.966 [INF] All done
unless = macro(cond, iffalse, iftrue) {
	quote(if !unquote(cond) {
		unquote(iffalse)
	} else {
		unquote(iftrue)
	})
}
unless(10 > 5, print("BUG: not greater\n"), print("macro test: greater\n"))
fact = func(n) {
	log("called fact ", n)
	if n <= 1 {
		return 1
	}
	n * self(n - 1)
}
a = [fact(5), "abc", 76 - 3]
m = {"key":a, 73:29}
print("m is:", m, "\n")
print("Outputting a smiley: 😀\n")
first((m["key"]))
12:50:10.967 [INF] All done

relates a bit to #38

@ldemailly ldemailly mentioned this pull request Aug 1, 2024
@ldemailly ldemailly merged commit 38a3f9d into main Aug 1, 2024
1 check passed
@ldemailly ldemailly deleted the func_obj_and_compact_print branch August 1, 2024 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant