I have a few random TADS 3 questions of a technical nature.
If I have a variable that is holding an object or a class, can I get a single-quoted string of the object/class’s name? See below.
class MyClass: object
getClassName() {
// how can I make it so this method returns 'MyClass', while
// subclasses return 'MySubclass', etc?
}
;
myObject: object
getObjectName() {
// how can I make it so this method returns 'myObject'? Is it same as above?
}
;
Is it possible for an object to have private variables in TADS 3, as in Java or .NET?
// Example:
class IntegerObject: object
private value = 0
get() { return value; }
set(val) { value = val; }
;
I imagine the answer is no, because (1) I’ve never seen this done in TADS 3 code, and (2) if this were possible, it would probably be done for things like Thing.location, which you’re not supposed to modify directly. Still, I just feel like asking just to make sure, since I’ve never actually read that this is impossible.
I’m working on a TADS 3 project that will be writing out to, and reading in from, an external file. If unencrypted, the file would be a tab-delimited text file, but I will eventually want it to be encrypted.
a.
I’m no cryptography expert, but the idea that popped into my head was to bit-shift each byte of text based on a set of crypto keys. For this to work, it would need to be a non-lossy “circular” bit shift (en.wikipedia.org/wiki/Circular_shift), but TADS 3 bit-shifting operators are the lossy kind, so I don’t know if my idea would be easy or would run efficiently. If anyone can offer any suggestions on how (and whether) to do this, I’d be grateful.
b.
Or if you have a better idea on how to to encrypt a text file, I’d be glad to hear any suggestions. I’m most apt to go for whatever idea is easiest but also secure and fairly efficient.
Thanks,
Greg