nicoplv
(nicoplv)
August 25, 2025, 3:46pm
1
Hello everyone,
Why does implementing the subscribable(int) interface on a class cause compilation to fail with the following error?
Script error 3502: Using a value of type type{(:int->void):cancelable} as a value of type type{(:any->void):cancelable} is not yet implemented.
In VS Code, no issue is reported, so is this a bug?
Here is my code :
simple_event_test<public> := class(subscribable(int)):
Subscribe<override>(Callback:int -> void)<transacts> : cancelable=
...DO SOMETHING...
The Subscribe method should take an int parameter, so it looks correct to me. Why is the compiler expecting a parameter of type any instead?
What’s the proper way to implement the subscribable interface?
(Even if I define my own subscribable, I hit the same problem. The only workaround I’ve found is creating subscribable_int, but then I’d also need a listenable_int, etc., which isn’t very practical.)
nicoplv
(nicoplv)
August 26, 2025, 8:27am
2
I haven’t found any solution except rewriting all my parametric interfaces as non-parametric ones.
For example, for the int type:
awaitable_int<public> := interface:
Await<public>()<suspends>:int
subscribable_int<public> := interface:
Subscribe<public>(Callback:type{_(_payload:int):void}):cancelable
listenable_int<public> := interface(awaitable_int, subscribable_int):
signalable_int<public> := interface:
Signal<public>(_payload:int):void
event_int<public> := class(listenable_int, signalable_int):
var Callbacks<internal> : [guid]type{_(_payload:int):void} = map{}
Subscribe<override>(Callback:type{_(_payload:int):void}) : cancelable=
bGuid := guid{}
bCancelable := cancelable_callback{OnCancel:=LoomioMess.handler_none_transacts(guid){ExtraPayload:=bGuid, Callback:=InternalCancel}.Handle}
set Callbacks = Callbacks.Add(bGuid, Callback)
return bCancelable
InternalCancel<protected>(_guid:guid)<transacts> : void =
set Callbacks = Callbacks.RemoveKey(_guid)
Signal<override>(_payload:int) : void =
for(iCallback : Callbacks):
iCallback(_payload)
Await<override>()<suspends> : int=
bEvent := event(int){}
Subscribe(LoomioMess.handler_generic(int, event(int)){ExtraPayload:=bEvent, Callback:=AwaitCallback}.Handle)
bEvent.Await()
AwaitCallback<protected>(_payload:int, _event:event(int)):void=
_event.Signal(_payload)