Not logged inOpenClonk Forum
Up Topic Development / Developer's Corner / :LongID
- - By Newton [de] Date 2010-12-15 16:55
Almost a year ago, there was a discussion about the introduction of the long ids. At that time, we switched from the old 4-character CLNK IDs to the new variable Clonk IDs. IIRC we agreed that the IDs from the object definitions should have a prefix to distinguish them from (other) variables. But an agreement is worth nothing if nobody implements it. So this is what happened for that:
http://bugs.openclonk.org/view.php?id=184

So we have two alternatives now,
1. just drop it or
2. someone is found that implements that

I wouldn't mind a drop btw since it didn't turn out that variables do clash with IDs because the naming scheme for variables always starts with a small letter.
Parent - By Maikel Date 2010-12-15 17:32
IDs do clash with functions though, still I am not for intrucing the :Id.
Parent - - By Zapper [de] Date 2010-12-15 17:38
It's just a naming convention. You can also replace that ":" by "_" for example (or "ID_").
Real namespaces on the other hand.. :)
Parent - By Sven2 [de] Date 2010-12-15 17:55
I'm pretty sure you cannot use : in identifiers at the moment. So it's more than just a naming convention.
Parent - - By Günther [de] Date 2010-12-15 19:42
I'm not going to artificially separate IDs and global constants at this point, but I'd like to allow additional characters in identifiers. Making the namespace bigger is the simplest method to avoid clashes :-)

I think we can use :. $ is used by other languages, and disabling string table stuff outside of strings is on the agenda already. Any suggestions for other characters?
Reply
Parent - By Isilkor Date 2010-12-15 19:43
@
Reply
Parent - - By Ringwaul [ca] Date 2010-12-16 01:23
Is # used anywhere yet?
Reply
Parent - - By Sven2 [de] Date 2010-12-16 09:47
Yes, in preprocessor directives like #include and #appendto.
Parent - By Ringwaul [ca] Date 2010-12-16 19:37
Ah, true.
Reply
Parent - - By Caesar [de] Date 2010-12-16 12:29
§° (Do other keyboards have that?)
Where do we use . by the way?

Personally, I don't like the Idea of using all those special chars in identifiers. I'm used to [a-z0-9_] and I think changing that would have a bad effect on the readability.
Parent - - By Clonk-Karl [de] Date 2010-12-16 13:37 Edited 2010-12-16 13:40

> Personally, I don't like the Idea of using all those special chars in identifiers. I'm used to [a-z0-9_] and I think changing that would have a bad effect on the readability.


I agree with you. I think this hasn't been a problem so far, and when allowing more characters in identifiers then we restrict the options we have when introducing new features to C4Script syntax, such as proper namespaces.
Reply
Parent - - By Sven2 [de] Date 2010-12-16 14:01
How about we only allow ::, but only if preceded and followed by at least one more other character?

This would allow identifiers like MyAddon::Clonk. If namespaces are introduced at some later point, it will still be compatible, but point to an identifier within a namespace.
Parent - - By Newton [de] Date 2010-12-16 14:17
MyAddon_Clonk
Parent - By Zapper [de] Date 2010-12-16 16:59
Parent - By Günther [de] Date 2010-12-16 20:54
C4Script already has proper namespaces, and they use “.”.
Reply
Parent - - By Sven2 [de] Date 2010-12-16 13:58
Neither § nor ° are on my keyboard :(

Standard US English keyboard I think.
Parent - By Ringwaul [ca] Date 2010-12-16 19:40
I modified my default keyboard layout so I can type °. :/ We don't normally have the degree symbol for some wacky reason.
Reply
Parent - By Clonk-Karl [de] Date 2010-12-16 13:38
Allowing : in identifiers would create ambiguities with the array slicing syntax:

var array = [1,2,3,4,5,6];
var foo = 5;
var :foo = 3;
array[:foo] // array[3] or array[:5]?
Reply
Parent - - By Asmageddon [pl] Date 2010-12-16 15:57
Perhaps make them optional, but proper namespaces.
By default, the namespace would be NameOfModule::NameOfObject, but could be specified to be other.
When not using a namespace in name of object, it first checks in module the mission/map is in, then in modules used by the mission/map, then in main module, and finally in other ones.
This way nobody would even have to write them in order .
As for a prefix, I don't think it would be useful. Just check if the name contains double :'s, perhaps adding a prefix when compiling scripts into bytecode/IR.
Btw, does OC use JIT compilation?
If not, then some of you might find this to be of interest: http://llvm.org/docs/tutorial/
I didn't read it yet, but I intend to.
Reply
Parent - - By Isilkor Date 2010-12-19 21:09
I have actually already looked at and built LLVM, but the resulting libraries are too large for my taste (we're talking about roughly doubling of the size of the executable).
Reply
Parent - By Asmageddon [pl] Date 2010-12-20 15:12
Well, but you can't say that having all the scripts JIT-ed(and thus much faster) wouldn't be pretty cool :>
Reply
Up Topic Development / Developer's Corner / :LongID

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill