brick-lang / brick

The Brick language spec
University of Illinois/NCSA Open Source License
31 stars 0 forks source link

Experimentation #5

Closed weswigham closed 10 years ago

weswigham commented 10 years ago

I feel like a more complete/cohesive example or Brick's syntax would be nice. A simple IRC bot like this one would go a long way towards such an example. I've tried to capture what I have learned about the syntax thus far, but there will invariably be some errors in what I've assumed, it would be awesome if you could correct me and we could see how something like this would work.

toroidal-code commented 10 years ago

Some of the incorrect syntax in here is just from me not updating the docs properly. >.> I'll fix those first.

toroidal-code commented 10 years ago

Any method with side-effects should have a ! as part of the name Any method that evaluates to a Bool should have a ?

toroidal-code commented 10 years ago

If a cond only has one case and a default case, if <block> else <block> is better.

toroidal-code commented 10 years ago

I'm not sure how we should go about global constants. Maybe the Rust const <id> = <expr> would work?

weswigham commented 10 years ago

Wouldn't a let in the global scope be a global?

toroidal-code commented 10 years ago

If we were to allow let at a top-level, all of those statements would actually be let!s as we're modifying current scope, not creating a new one.

toroidal-code commented 10 years ago

Is this based on the Haskell IRC bot? Just wondering for reference.

weswigham commented 10 years ago

This is totally based on the haskell IRC bot. (Albeit, with shortcuts made based on personal preference)

toroidal-code commented 10 years ago

Alright, let's do the top-level lets as separate let!s. ifs and elses don't need the stabby arrow, as they are eagerly evaluating the block below them on that condition. Neither do !quit and !id. The lambda syntax is sufficient there |thing| { puts thing }, since that evalutates directly to a Function instance.

toroidal-code commented 10 years ago

Since these are all really trivial, I'm going to pull, close, edit, and then squash.