RPC function parameters #208

Open
opened 2022-03-03 16:30:19 +08:00 by sb10q · 1 comment

artiq_sinara_tester contains this:

    @kernel
    def get_sampler_voltages(self, sampler, cb):
        ...
        smp = [0.0]*8
        sampler.sample(smp)
        cb(smp)

    def test_samplers(self):
       ...
       voltages = []
       def setv(x):
           nonlocal voltages
           voltages = x
       self.get_sampler_voltages(card_dev, setv)

While I can easily work around the issue here, do we want to support this code pattern in NAC3?

What type annotation should we have for cb? I suppose the annotation would have to be specific for RPCs, since the codegen is different between RPC and non-RPC.

``artiq_sinara_tester`` contains this: ```python @kernel def get_sampler_voltages(self, sampler, cb): ... smp = [0.0]*8 sampler.sample(smp) cb(smp) def test_samplers(self): ... voltages = [] def setv(x): nonlocal voltages voltages = x self.get_sampler_voltages(card_dev, setv) ``` While I can easily work around the issue here, do we want to support this code pattern in NAC3? What type annotation should we have for ``cb``? I suppose the annotation would have to be specific for RPCs, since the codegen is different between RPC and non-RPC.

I think we don't need a special type annotation. We can just put the RPC code inside a function and pass the function pointer to that wrapper function.

Supporting this should not be too hard after implementing function pointer.

I think we don't need a special type annotation. We can just put the RPC code inside a function and pass the function pointer to that wrapper function. Supporting this should not be too hard after implementing function pointer.
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: M-Labs/nac3#208
There is no content yet.