Stefan,

"is" is what I was looking for!. My use case is not very complicated as I'm 
just trying trying to learn by experimenting. The code was just an example.

I have some ideas on a project I want to make using nim, for example a 
translator that converts a markup to groff code.

The idea being to read the input and convert it to an AST, then traverse the 
AST, generating groff code based on the node type.

However after experimenting a bit more, I think what I have in mind is best 
achieved by writing a variety of "generate" methods each accepting a different 
parameter type, and leveraging dynamic dispatch to let the compiler decide 
which "generate" proc to use, depending on which node type is passed to it.

This way I could traverse the AST recursively, simply calling the same proc 
over and over.

for example:

method generate(element: H1) : string method generate(element: H2) : string 
method generate(element: UL) : string method generate(element: LI) : string 
method generate(element: P) : string

All this to say, although "is" is what I had in mind when posting the question, 
I'm realizing I may not need it after all if I leverage methods :)

yc

Reply via email to