kototama kototama writes:
> How can I generate a tag for a function having multiple arities? Let's
> say for example that my function 'f' has a definition for two
> arguments and another definition for three arguments. They are, in
> Clojure, defined like this:
> (def f
> ([a b] (some-code))
> ([a b c] (some-code)))
> How can this be expressed in Semantic?
There's is no built-in feature to express that as a tag. You could
create two tags with different :argument lists, similar to function
overloading in C++. However, this will probably not magically work right
away; you will still need to add code which makes sense of the multiple
definitions of 'f', for example when
semantic-analyze-possible-completions is called.
If you don't like that solution and would like to have a single tag: you
are free to extend tags with your own attributes as you'd like. For
example, you could produce a tag with an :arities attribute which
contains a list like '( ("a" "b") ("a" "b" "c") ), but then you would
have to teach Semantic how to deal with that by overriding the necessary
Semantic isn't very good at dealing with such polymorphisms. It gets
worse when dealing with types, but fortunately you're dealing with a
dynamic language. :-) We were planning to implement an API for that
(when I dealt with C++ templates), but we never got to that.