Feature - Implemented bitwise operators

Do they exist? I tried using & and | in place of && and ||. None of the four worked.
I suppose it's not very common to be doing heavy math in mafia, but I can see its place in settings and things.
 
perhaps you don't understand.

20 && 4 should return 4.
20 && 5 should also return 4.

Seems no matter what I use, the second number is always the result.
 
In my case, setting/reading permissions on a per-user basis without requiring a whole slew of variables.
Though if they existed I could see myself taking them elsewhere in my scripts.

And to BCC, yes, I know && is logical And. If you read the title of the thread, you'd see that that is not at all what I was asking for.
 

StDoodle

Minion
I could see the use of bitwise operations for a small number of things, like setting up which war sidequests you'd like done, but I don't think you're really going to be able to save yourself all that much work scripting-wise, as you'll have about the same amount of code bit-checking as coming up with some other solution, like custom records or maps.

Perhaps more info on what types of settings you're looking to handle would help someone come up with a solution that might be just as easy?
 
Well, my other option would be to just use a map to save permissions. Which, I think, is ridiculous. (and annoying for those of us that tend to edit map-files by hand.)

I'm checking the username of an incoming PM against a permission file. In which case if there's no bitwise operators in ASH, I'll just write a library for it.
 

Bale

Minion
This seems a reasonable feature request. However I cannot see this being high priority to one of the dev's limited time unless you can explain it in a way that is more exciting.

I think that you'd have an easier time writing your library function and convincing zarqon to add it to zlib. This definitely seems more like a zlib function, so please post the function you write.
 
I'd only be writing library functions for it because I have no better way to implement it.
I'm not sure what "excitement" has to do with a feature. If it benefits the language as a whole (and I understand that ASH isn't mafia's main feature) then it should be implemented. I don't feel that operators should be functions. They are -operators-.

If I come up with a concise and elegant solution for them, I may submit them to zarqon, but really, if only I'm going to be using them, then why bother.
 

Bale

Minion
I'm not sure what "excitement" has to do with a feature. If it benefits the language as a whole (and I understand that ASH isn't mafia's main feature) then it should be implemented. I don't feel that operators should be functions. They are -operators-.

"Excitement" is important because the devs of KoLmafia are not being paid and they only do this in their extremely finite spare time. If it isn't interesting to them or obviously necessary, then they aren't going to try to find the time to do it.
 

Theraze

Active member
It's not necessarily 'wow' factory, but more the 'why' factor. While it may be useful, in fairly limited circumstances, if it can be hacked easily without needing additional coding, then the 'why' factor comes into play. If you can show that the circumstances of usefulness are broad, or that it will make people's lives easier in an obvious way, then it's more likely to happen.

Or, y'know, if we decide that we want it/notice the bug/miss out on something the day after it's been hyped up again.
 
I know this probably won't constitute anything close to the "why" of which you speak, but it is rather just how I feel about the subject. While the uses may be somewhat limited in this environment, there is a time and place for it, and this request in particular is something that I feel (personal statement) should simply be a part of any language by default. Built-in bit operators are orders of magnitude more efficient than any function I could muster with the given math set (not that efficiency is really a huge issue with 100% of the scripts).
Good metaphor here would be Collector's Score.
ASH doesn't need bitwise operators to work, but it would feel more complete if it had them.
 

fronobulax

Developer
Staff member
I know this probably won't constitute anything close to the "why" of which you speak, but it is rather just how I feel about the subject. While the uses may be somewhat limited in this environment, there is a time and place for it, and this request in particular is something that I feel (personal statement) should simply be a part of any language by default. Built-in bit operators are orders of magnitude more efficient than any function I could muster with the given math set (not that efficiency is really a huge issue with 100% of the scripts).
Good metaphor here would be Collector's Score.
ASH doesn't need bitwise operators to work, but it would feel more complete if it had them.

I have not searched and linked to the comment/discussion but ASH has its origins in an undergraduate computer science course requirement.

I find your comment that bit wise operators should be a part of every language "by default" to exhibit a fairly narrow understanding of the state of the art in computer language design. On the off chance that you know something that I don't, would you be willing to digress and explain why you believe that?

I find your concern for efficiency puzzling since ASH is a scripting language that runs in KoLmafia which itself is "compiled" but only to a platform independent intermediate that still has to be interpreted on each specific platform. Perhaps you are measuring efficiency in terms other than run time?

I confess to having a professional bias against bit wise operators and the associated data representation. Care needs to be taken in the coding or the code is not portable (Big vs Little Endian, for example) and at least one Fortran compiler in the 1980's had an implementation that made using them measurably slower. Furthermore, it is difficult to write understandable source code that makes the mapping between bit positions and items of interest visible and difficult to extend when the number of elements increases and crosses a representation boundary.

On a practical basis there are about 10 people who have commit access for KoLmafia (i.e. they can change the code and have their changes propagated to the official distributed version). Three of those people committed about 90% of the code. Only one is currently "active". So the way in which features are implemented are two - either the proponent for the feature convinces someone with time, understanding and commit access, that the feature is worth implementing or the proponent implements the feature themself, posts a patch here and then badgers someone with commit access to commit the patch on their behalf. Hence the comments about the "wow" factor.
 

Veracity

Developer
Staff member
Big Endian vs. Little Endian only really matters if you are transmitting data from one computer to another with a different architecture. If all the data stays on the same computer, it's not an issue.

Adding new operators to ASH is actually reasonably "fun". I like extending the language, as I did earlier this year, for example, with +=. Adding arithmetic and, or, xor, and complement would take a couple hours to code, test, and submit, max, I'd estimate.

There is the "free time" vs. the "useful to lots of ASH programmers" axis, though. A "couple hours" for something that doesn't affect ME directly is hard to justify at this time of my life...
 
I understand that efficiency isn't something that can necessarily be considered, because Java is merely an interpreter at heart, but that doesn't mean that using built-in Java math operators is -as slow- as writing code to do the same thing. Interpreting might be slow, but your statement implies that interpreting once and then again wouldn't be any slower.
Java natively supplies bitwise operators, it would merely be a matter of supplying functionality to the ASH interpreter, which would execute quite a bit faster than converting a function using quite a bit of division and if-checks to get one bit out of four bytes. SHL and SHR (in java I believe "<<" and ">>") would probably be the only addition that might require checking big vs little endian, but again, Java would make that check for you.
When I said "every language" I may have been oversimplifying my beliefs. I can think of a few instances where the inclusion into the language would be excess or redundant. In procedural and functional languages, the inclusion of math functions [and bit manipulation] are generally aspects of the implementation. Most of my work has been in compiled code, not interpreted code, so if that has a bearing, then I apologize for my misunderstanding. And, I must emphasize this more strongly than I did last, the necessity of this ability is entirely a personal belief.

If you would care to illustrate the "state of art of computer language design" that would be wonderful, since the way it's written I don't understand at all what it is you are trying to say, other than the inferred stab at my knowledge in the subject.
 

Fluxxdog

Active member
Hitler.
Now can we stop this code standards "holy war" before it really kicks in? Next thing you know it's gonna be a Debian v Red Hat v Slackware war. Oy.
The question should be "Is this something that can be developed for mafia's benefit, something that could be acceptable as a 3rd party patch, or rejected altogether?"

(I swear, I've seen uglier things on the net, but not many.)
 
Top