Skip to content

Comment on Experiments with Nimrodparent

Comments

I'm looking forward to ROS2 using DDS, which will give zero copy IPC for nodes on the same computer. [1]

I wouldn't say that Rust is bad at talking about compile time versus runtime, just that Nimrod is better. This throws a compile error in Rust, for instance:

      static FOOBAR: int = if 2i > 1i { 10 } else { 20 };
But this doesn't in Nimrod:
  when 2 > 1:
    const FOOBAR = 10
  else:
    const FOOBAR = 20
And that's all because Nimrod added this 'when' keyword distinct from 'if' for stuff that gets computed at compile time. I wouldn't need something like that in a non-embedded context (I guess it's used for specializing to a given operating system by the creator?) but I'll happily use it.

[1]http://design.ros2.org/

Keep in mind that Nimrod will also try to evaluate normal code at compile-time, so the following will work fine:

    const FOOBAR = if 2 > 1: 10 else: 20

What I'd actually be doing is more like:

  when ROBOT_VER == 32:
    type TSonarAddresses = array[0..3, int]
    const sonarAddresses: TSonarAddresses = [1,2,3,4]
    ...
  elif ROBOT_VER == 33:
    ...
and stuff like that.

I see. Good, that is precisely what 'when' should be used for :)

This is called "constant folding", and every better compiler should do that.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.