Typed parameterized functions in a semantic model

I’ve implemented most of my semantic model for a type checker; now just missing Java-like interface implementation verification logic.

I’ve something that I’m not safe about: how to structure symbol for functions such as:

function f.<T>(v:T):void {}

(This is written in my language, VioletScript.)

Not tested yet, but that’s how I did it: violetc/MethodSlot.cs at master · violetscript/violetc · GitHub

I’m representing a function (aka. “method slot”) as either:

  • normal
  • instantiated (obtained from a base object that is an instantiated type)
  • instantiation of another type-parameterized method slot

Appreciate any feedback!

You mean, how to design the syntactical structure of a generic method?

If so, I would wonder why there is a dot behind the function name, before the generic types list opening ‘<’?
Without knowig your grammar, assuming it is quite C-like, it should not be necessary even for an LL(1) language, I guess…

Otherwise it looks quite pretty.

1 Like

About the syntax, I followed EcmaScript 4 (ActionScript 3) convention for the generic syntax. I’m aware that the Java syntax for these is a bit more complex to parse, but, yeah, I’m kinda OK with that dot.

My question was about semantic model though, how to properly structure a symbol for a generic method. I re-analyzed my C# code and it seems fine, but I’m open to feedback!

1 Like