Bog – small, strongly typed, embeddable language
1–10 of 55 posts
Re: Bog – small, strongly typed, embeddable language
#2> let {print} = import "std.io"
An idea obvious in hindsight that I hadn't thought before - if import returns an environment and let can destructure, then a pattern match can bind an explicit subset of that import. Something like:
`(let {print read} (import io) (print (read)))`
Further down I find essentially that example (with input instead of read) and destructuring assignment within function arguments:
`let add = fn ((a,b)) a + b`
though the grammar suggests that {} is initialisation and not a map/dict/hash/assoc/environment style thing, so you probably don't have `fn ({key value}) value + 4` or similar for taking maps apart as they are passed to a function. Thus I think import is special cased.
The bytecode layer knows what maps are though, so maybe they're just missing from the syntax
Re: Bog – small, strongly typed, embeddable language
#3Re: Bog – small, strongly typed, embeddable language
#4How are coroutines scheduled?
Can suspend return a value?
Re: Bog – small, strongly typed, embeddable language
#5Re: Bog – small, strongly typed, embeddable language
#6Thank you for posting this. > let {print} = import "std.io" An idea obvious in hindsight that I hadn't thought before - if import returns an environment and let can destructure, then a pattern match can bind an explicit subset of that import. Something like: `(let {print read} (import io) (print (read)))` Further down I find essentially that example (with input instead of read) and destructuring assignment within fun…
Some languages have foo.somefunc() which I think works quite well although iffooisrealllylong.function() is a risk.
I suppose this gets you the best of both worlds.
Although using let does seem a bit weird to me. It seems conceptually misleading.
Re: Bog – small, strongly typed, embeddable language
#7Thank you for posting this. > let {print} = import "std.io" An idea obvious in hindsight that I hadn't thought before - if import returns an environment and let can destructure, then a pattern match can bind an explicit subset of that import. Something like: `(let {print read} (import io) (print (read)))` Further down I find essentially that example (with input instead of read) and destructuring assignment within fun…
Re: Bog – small, strongly typed, embeddable language
#8I'm not sure how I would embed this in a non-Zig project, though.
Re: Bog – small, strongly typed, embeddable language
#9Thank you for posting this. > let {print} = import "std.io" An idea obvious in hindsight that I hadn't thought before - if import returns an environment and let can destructure, then a pattern match can bind an explicit subset of that import. Something like: `(let {print read} (import io) (print (read)))` Further down I find essentially that example (with input instead of read) and destructuring assignment within fun…
Re: Bog – small, strongly typed, embeddable language
#10Pretty interesting. I'm a professional user of Lua, and while I love it, I really get frustrated at a lot of aspects of it, especially how loose the typing is. I've long wished there were more strongly typed alternatives, but just nothing compares to the performance, stability, and quality of documentation of Lua. I'm not sure how I would embed this in a non-Zig project, though.