REALbasic has a Permissions object which is used with FolderItems to assign the UNIX-style permissions for the FolderItem. One very common gotcha that I've seen several bug reports on is forgetting to specify in Octal instead of Decimal (these reports are Not a Bug).
The documentation on the Permissions class points this fact out to you, but it is still blindingly easy to forget since most people don't use octal ever. Basically, what people mix up is this:
// Set Read/Write/Execute on Owner, and Read/Execute on Group and Others -- WRONG!!
Dim perms as new Permissions( 755 )
Oops! That's a decimal value, which corresponds to &o1363 in Octal. That would translate to bad things (Write/Execute on Owner, Read/Write on Group and Write/Execute on Others -- oh and the Sticky bit would be set. Yoiks! Instead, it should be written as this:
// Set Read/Write/Execute on Owner, and Read/Execute on Group and Others
Dim perms as new Permissions( &o755 )
So if you use the Permissions object at all, double-check your code to make sure you're actually setting the permissions the way you truly intend. This only matters if you're using hard-coded permissions integers instead of assigning to individual fields of the class.
This is another case where compiler warnings would be useful. There's no question that's a common error, and it would be nice if the IDE guided us by the hand... :-)
The compiler can't really help you much with this though. From its perspective, both are integers, and perfectly valid ones at that. For instance, there's no reason you *can't* specify 755 in decimal; it's a perfectly legal value for the permissions object.
Yes, I understand that 755 is perfectly legal in decimal. But the compiler could certainly apply some heuristics to the value (basically, see if the original representation was in decimal and if the corresponding octal notation makes more "sense" subjectively) and issue a warning in suspicious cases.
Obviously this would only work for constant-value assignments.
Just pointing out a neat way the IDE can be as helpful as possible. That's what REALbasic is all about.
It's a good idea in theory, but in practice, it's not possible. The compiler doesn't see things in terms of "hex" or "octal", etc. It sees "integer" or "double". The permissions object takes an integer, which means any integer is legal. There's no way for the compiler to warn you about this unless "Octal Integer" became a datatype.
Hmmm. I certainly understand that one level of the compiler only sees it as an integer. I'm merely suggesting that the compiler could store the "source representation" of a constant integer--whether it's octal, decimal, etc.--and use that information at a deeper level (when parsing the Permissions constructor) to determine if it should issue a warning. Now that I think about the complexity necessary for that, I'm inclined to agree that it's not desirable (although I still argue it's possible!). Plus, does seem inelegant.
Perhaps an IDE "tip" (remember those?) would be in order. A status bar message could pop up whenever you start a Permissions constructor and use a suspicious decimal representation. I've always thought that status bars are too easy to ignore, but it's better than nothing (or a whole new complex warning architecture).
Anything is possible, but that's a huge mess for one little gotcha. ;-) The tips idea is a much better approach to the issue since it's still localized, and doesn't involve kludging the compiler. :-)
It sounds like you're saying that the compiler doesn't tokenize 755, &o755, and &h755 into different token types and then convert them to "integer", "double" etc.
That would seem kind of odd.
However, I'd agree that it's a tough thing to solve because there are no strictly identifiable values that are obviously bogus and that could be used to indicate an error.
For instance, decimal 493 is octal 755 so both are sensible values.
The compiler does tokenize it, but they're all defined as "integers", which is the same type as the parameter. That's why I said it's not possible without defining a new datatype, essentially.
I suppose RB could use the tokens as the basis of the warning BUT this is still one that has no "right" answer.
A person does not HAVE to use octal so if you flag a warning on the basis they use a decimal constant that would be a problem. 493 is perfecty fine as a set of permissions; it's just unusual to specify them that way.
Flagging that as a warning would be a problem for anyone that used decimal.
The other thing is there's no real "warnings" in the RB compiler. Things compile or they don't. Making it so RB culd say "hey this is a bad practice but it compiles" would be a nice thing
I filed a feature request to improve the LR documentation on this point.
http://www.realsoftware.com/feedback/viewreport.php?reportid=hkxilene