Dictu icon indicating copy to clipboard operation
Dictu copied to clipboard

[FEATURE] move bitwise operators into standard library

Open gvwilson opened this issue 3 years ago • 3 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Is your feature request related to a problem?

If iterators, fibers, or other features are going to be added to Dictu, other features should be taken out so that the source doesn't become bloated. Bitwise operations are a good candidate: they are rarely used in high-level languages and they can easily be provided as native functions in the standard library.

Describe the solution you'd like

  1. Remove &, |, ~, ^, <<, >>, and associated update operators from the scanner and compiler. (I can do this.)
  2. Provide native functions bit_xyz to replace them. (I can do this.)

Describe alternatives you've considered

No response

Additional context

No response

gvwilson avatar Dec 26 '21 20:12 gvwilson

This is an interesting proposition, I can't think of any language off the top of my head that doesn't implement them as operators rather than all as builtins (not to say there aren't any languages, I'm sure there are). Obviously other languages don't have to define Dictu, but deviation is extra learning.

Operators do cause a bit of bloat within the compiler at the moment as there are about 3 places that need to be changed when adding a new operator, so I'm not entirely opposed to the idea.

Jason2605 avatar Dec 26 '21 23:12 Jason2605

FORTRAN didn't have 'em, but I'm showing my age there :-) More seriously, I think Dictu's already a medium-sized language; if more features are going to go in, it's the right time to think about what can be taken out. Bit ops are an obvious candidate...

gvwilson avatar Dec 27 '21 00:12 gvwilson

Hah thats interesting, I can't say i've ever used FORTRAN! I'd potentially be up for moving bitwise ops but I think having them behind some sort of namespace would probably be advised. I'm trying to keep the amount of non-namespaced builtins low to stop the chance of unknown shadowing (although for bitwise funcs thats probably going to be a pretty low chance).

I'm not sure which namespace they would live behind yet though 😅 Perhaps even a new one which can be extended with other bit-twiddling functionality at a later date

Jason2605 avatar Dec 27 '21 01:12 Jason2605