sharkdp / numbat

A statically typed programming language for scientific computations with first class support for physical dimensions and units
https://numbat.dev
Apache License 2.0
1.26k stars 53 forks source link

Add explicit use statement for non-prelude functions to examples #604

Closed Bzero closed 1 month ago

Bzero commented 1 month ago

Resolves #602.

sharkdp commented 1 month ago

Should we maybe add an additional >>> here?

image

Bzero commented 1 month ago

We can do that. Would you do it for all multi-line examples or only here with the use statements?

Goju-Ryu commented 1 month ago

I’m thinking all of the multi line examples to make it clear what is input and what is output.

sharkdp commented 1 month ago

Just be aware that there might be multi-line expressions which should not be formatted this way. So something like

fn f(x) =
  x² + 1

should not be rendered as

>>> fn f(x) =
>>>  x² + 1

because it needs to be entered as a single line.

The easiest (and possibly best?) option might be to get rid of the >>> prompts all-together?

Bzero commented 1 month ago

Yes, it would not be straight forward to distinguish those cases.

The easiest (and possibly best?) option might be to get rid of the >>> prompts all-together?

I think the >>> prompts help to distinguish in and output in the examples, especially for the many one-liners we have so I would prefer to keep them. How about adding additional whitespace to the start of the lines to get a common indentation?

sharkdp commented 1 month ago

I think the >>> prompts help to distinguish in and output in the examples, especially for the many one-liners we have so I would prefer to keep them.

But we also have an indented equals sign for the outputs. So we would go from

>>> floor_in(m, 5.7 m)

    = 5 m    [Length]

to

floor_in(m, 5.7 m)

    = 5 m    [Length]

I don't really see a problem with that. I think I even prefer the latter one. Some users might not immediately understand that >>> is supposed to be a prompt.

Bzero commented 1 month ago

Yes that's true as well, I think it's fine to remove it then.