Live data from Hacker News

Bog – small, strongly typed, embeddable language

github.com

1–10 of 55 posts

Re: Bog – small, strongly typed, embeddable language

#2
Thank 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 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

#6

Thank 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…

Something I hate about about c is that you don't know where the hell somefunc() came from.

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

#7

Thank 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…

Funny, I find this syntax very obtuse: it looks to me like "print" is being defined as, well, the print function, through a very roundabout name collision. What happens if there is a typo and the code says: let {ptint} =... What error message comes up?

Re: Bog – small, strongly typed, embeddable language

#8
Pretty 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.

Re: Bog – small, strongly typed, embeddable language

#9

Thank 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…

Isn't this exactly what CommonJS does/did?

Re: Bog – small, strongly typed, embeddable language

#10
post #8

Pretty 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.

There’s a C embed example in the examples folder
Post reply on HN