AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

enum functionality in chatscript
 
 

I have defined a few outputmacros, where I want to check some parameters at compiletime.

To make a simple example, I would have a function with one paramater, which i want to be “valueA” or “valueB”.

outputmacro: ^foo(^arg1

now I want to prevent myself, that if I just make a typo, i have the risk of not recognizing it and having my program not working. This would maybe a mistake, which is hard to find.

To prevent this I want to do a check at compiletime.

For simple cases I could think of writing wrapper functions, which would be in the case above:

outputmacro: ^fooValueA()
^
foo(valueA)
outputmacro: ^fooValueB()
^
foo(valueB)
outputmacro: ^foo(^arg1

This way is not that elegant and gets hard if you have more possibilites and a function which takes more arguments, because than you would have to write a lot of wrappers.

Can you think of another way to do it?

 

 
  [ # 1 ]

Don’t think this can be done at the compile time without the introduction of a type system. But it should be common practice to validate/sanitize/default all parameters within a function and so checking that a value is a member of a concept (CS’s equivalent of an enum) or a number or a date are all the same class of problem. Any issues can be logged and use %rule or ^getrule() to print out helpful context information.

 

 
  login or register to react