Conversation
|
Another huge feature in the works, thank you. Can there be more than 26 capital letters to draw a type
|
I wonder if it would be feasible to implement type inference (maybe later, not necessarily now): |
ed77edd to
fd5fb23
Compare
|
is it just new structure of function in vim9script? |
|
WOW no errors |
A generic function allows you to operate on different types of data without losing type checks and https://en.wikipedia.org/wiki/Generic_function |
c7cfaca to
75ea81b
Compare
0ff2ce8 to
dac21eb
Compare
I wonder if the problem from #17313 (comment) comes from the same place? (except that one doesn't crash vim, it gets a runtime error) |
Yes. This is a bug. Good catch. I have updated the PR to address this issue.
|
Oh, well. The crash is still there. But the |
|
It is nice that constructors can be parameterised like other
|
In the future there might be generic classes, something like Are there any considerations now to insure that adding generic classes in the future won't run into syntactic issues to make a class generic if there are already generic functions in the class? I guess the general case is that a function has both type variables from the class and some of it's own. |
Thanks for reporting these issues. This should be addressed by the latest PR.
|
No. These two issues are different. I have addressed the issue with extending generic class |
I will work on the generic class support after the current PR is merged. I don't expect |
|
A couple more issues:
|
Thanks for reporting these issues. These should be addressed in the latest updated PR. |
|
Set and List operations can now be generified (see below)! Supporting generic constructors for Congratulations and thank you for developing this feature,
|
vim9script
def Foo()
echomsg "Foo"
enddef
def Bar<T>()
echomsg "Bar"
enddef
var A = Foo
var B = Bar<string>
A()
B()
disassemble A
disassemble Boutputs |
vim9script
def Foo<T>(a: T)
var b: T = a
enddef
def Foooutputs |
Off topic, I didn't know, or had forgotten, that Doesn't seem to be documented. |
Thanks for reporting this issue. This issue should be addressed in the latest updated PR. |
Thanks for creating these example scripts. This exposed some existing memory leaks which were tricky to fix. |
This is supported now in the latest updated PR. |
|
I'm glad that this is taken care of. Oops, I don't have any |
Thanks for continuously testing and reporting the problems. |
|
Thanks, so I assume this is ready now? |
|
@yegappan, I'm sorry about that merge commit, I haven't the faintest idea where that came from. You may want to force push again. I have a 22 year old cat with hyperthyroidism and a love of keyboard dancing as my initial suspect. |
No problem. I did a force push again. |
@chrisbra Yes. This PR is ready. |
|
@yegappan and @chrisbra, I don't really consider it a blocker but, just in case it's been overlooked, function listing still needs some work. See: #17313 (comment) |
|
thanks all. Let me merge it and we can do further improvements with a followup PR for the function listing. |
A generic function definition:
A generic function invocation:
The following are supported:
The following are not yet supported: