If I have an identifier with a same name as existing keyword, how do I escape it?
Asked
Active
Viewed 165 times
2
-
hmm, I'm using boo in production about 2 years and never had such a question)) just googled and found nothing. – Sergey Mirvoda Dec 20 '09 at 20:56
-
I had to read boo grammar to find out more. :) – Andrey Shchekin Dec 21 '09 at 15:54
2 Answers
1
That's what I found (and this is probably the final answer):
- It is possible to use
@
as a prefix in identifier names. However, by default it creates a different identifier (@a != a
). - Since
@
is allowed, it is possible to add a new compiler step to the pipeline that will doTrimStart('@')
on all identifiers. It works ok, you will just have to remember all types of things that have names. - If you are using Rhino.DSL, it has a UseSymbols step that converts @a into 'a', which had confused me a lot (I was working with project that included this step by default).

Andrey Shchekin
- 21,101
- 19
- 94
- 162
-
and how that work?? how code like that can be produced to AST? ''class = "Hello I'm keyword"'' yes you can wrote @class, but it is _not_ a keyword. Also you should be able do than in different levels of a type i.e. fields, parameters, properties, methods etc. It's not an easy task )) – Sergey Mirvoda Dec 21 '09 at 17:31
-
also you should check that a = "Hello" @a = "Hello" after your step you can get non uniq names – Sergey Mirvoda Dec 21 '09 at 17:33
-
1_yes you can wrote @class, but it is not a keyword_ -- well, the difference is not obvious when you stay inside Boo, but consider a calling application in some other language where, for example, 'def' is not a keyword. In this case, difference between 'def _def()' and 'def @def()' is that it would be callable as 'x._def()' in the first case , and 'x.def()' in the second. – Andrey Shchekin Dec 21 '09 at 17:43
-
1as for the unique names, I know it, but it is the same as C# does it, so I (and other users) am quite accustomed to this. – Andrey Shchekin Dec 21 '09 at 17:44
0
I don't think anything like the C# @ prefix is implemented in Boo... but I'm pretty sure it could be achieved by inserting a custom compiler step to the beginning of the compiler pipeline.

Community
- 1
- 1

Mauricio Scheffer
- 98,863
- 23
- 192
- 275
-
I think it is not possible at all. compiler steps operates on AST. but which AST will be produced for such a code class = 'Hello' – Sergey Mirvoda Dec 21 '09 at 10:02
-
-
-
yes, and I am ok with compiler steps, but I was hoping that there is something that works out of the box. – Andrey Shchekin Dec 21 '09 at 16:33