Monday, 31 August 2020

Flock, Day 2

So I decided to rebuild LLVM following the instructions, it's taking a while to rebuild, but I think its better this way as LLVM version 10.0.1 has come out and the windows version needs a source build. I appear to of made a couple of errors in my first built.

  • Using the cmake gui, made life a lot easier, (although I had to learn the tool)
  • Ensuring the install and build directories don't have whitespace in the path also seemed to make a difference. If at first you don't succeed read the instructions, as my dad says. Although in my case, read the instructions more thoroughly.

So I think I want to cover some thoughts on syntax, in particular how we deal with removing Null/Nil.


I don't want nulls to be in the language. I could just insist all variables gets instantiated, and throw an exception if they aren't. However this is a pain as a developer, as often forcing instantiation, makes for some awkward code with a significant amount of error handling. 

The typical approach in languages and APIs is to specify an Option(al) variable, one that is either set or not. So your variable effectively wraps the instantiated one. If the instantiated version doesn't exist it is represented by 'None'. if it does it is represented by the wrapped variable, like 'Some' or 'Any'. Rust does this particularly well, by representing the 2 states as an enum. 

There is still some exposition style bagage here, in java you would call isPresent() or in Rust use some form of deconstruction, often you stick this logic into a switch, match or if statement. Which brings me to the use of syntax.

A common way to infer this logic is via the Elvis operator ?: this basically says, if not present default to the next bit. Alteratively ?. Says if present do the next bit, otherwise stop. This is definitely the way to go, and this short hand is top of my list. I would like to add some other syntactic sugar here for conformity. Additionally since we are a reactive language, being able to syntactically support errors is also quite useful, now using ! could also mean there is a problem, and we would use it a bit like onerror, or the catch, so maybe :! Defaults as on error, and .! Continue if no error. However we also use ! in logic statements, so this could get confusing. So I need to spend some time thinking about the cleanest way of differentiating.

You might at this point go 'doesn't this fly in the face of the rule to be symbol minimalist?' My answer 'Um.... yes, but I also want it to be easy.' Part of making a language is having to decide what feature is more important, and because its my language (for the moment) I get to make that choice.


It looks like it has just finished building, but family have returned and I have a dishwasher door to replace, the time just creeps away!


No comments:

Post a Comment

Flock Day 8

 It's been a very long time since I last posted, although I have been spending on average 2-3 hours a day cutting code since the last po...