Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Language Design: Force unsigned Bitwise Operations And Precedence of Operations
#7
(02-01-2016, 05:41 PM)A-Man Wrote:  been learning a lot reinventing wheels.
More like reinventing car. You're literally writing a script engine from scratch.

I wonder if you're using any kind of source control tool (usually 'git'). Don't wanna sound off topic but this is incredibly important. Doesn't matter if you want to share the source or not, you should be using it somehow (either locally or even better via GitHub). This makes it possible to revert things if something goes horribly wrong. Also you clearly see what you have changed with diff. Any programmer should (must?) know a fair amount of source control / versioning system.

(02-01-2016, 05:41 PM)A-Man Wrote:  The next point involves the precedence of operators. So one of the weird things that hit me was the annoying decision of giving bitwise operator like AND and NOT a lower precedence than most equality related operators (==, >, <..etc). Later I realized: I wasn't the only one, this was only in C++, and that there isn't really a standard order everyone follows; e.g: python's list is very different from C++. So yeah, I thought I could try coming up with one myself to make things more intuitive :P I used C++'s as a base, and the first thing to change was of course that. I also did stuff like give bitwise OR and XOR the same precedence, and added a couple of operators like python's exponentiation (**). Hopefully, there weren't something I overlooked, or was there?
This may come in handy:
http://dlang.org/spec/expression.html
I highly suggest you to not make it any different than what C language has, since it's creator(s) were actually mathematicians. Don't claim you know better than them ;) So you should not give AND operator higher precedence than comparison operators otherwise how do you expect it to work?
    C++-Code:
x <= 50 && x > 0

It will first try to execute 50 && x which doesn't make sense in any way.

Ohh, and I'm completely against pythonic comparison (from a compiler writer's point) 2<x<9. You should not bother making such syntactic sugars otherwise you are gonna have a bad time, don't make exceptional stuff because you will end up fighting for it all over the place. You need to think every possible situation and will need to put that exceptional code everywhere... Let the system work in it's normal consistent way.

(02-01-2016, 05:41 PM)A-Man Wrote:  Lastly, I'm considering trying to be very flexible with operand types. e.g:
- "text * number" is 'text' repeated 'number' times. I know this can be done in python.
- "text + number" is length of 'text' + 'number'.
- "text - number" is length of 'text' - 'number'.
- "text / number" is length of 'text' / 'number'.
-etc..basically any attempt to do arithmetic on text that is not otherwise supported will use the length of the text operand(s) instead.
No no no not never ever do this kind of things.
Ultimately, my constant dissatisfaction with the way things are becomes the driving force behind everything I do.
[Image: sigline.png]
LF2 IDE - Advanced visual data changer featuring instant data loader
LF2 Sprite Sheet Generator - Template based sprite sheet generator based on Gad's method
[Image: sigline.png]
There is no perfect language, but C++ is the worst.
Reply
Thanks given by: A-Man


Messages In This Thread
RE: Language Design: Force unsigned Bitwise Operations And Precedence of Operations - by NightmareX1337 - 02-03-2016, 06:42 AM



Users browsing this thread: 1 Guest(s)