Opened 10 years ago
Closed 10 years ago
#2885 closed enhancement (fixed)
Bind partially evaluated function to local component
Reported by: | Per Östlund | Owned by: | Martin Sjölund |
---|---|---|---|
Priority: | normal | Milestone: | 1.9.1 |
Component: | MetaModelica | Version: | trunk |
Keywords: | Cc: |
Description
It doesn't seem possible to bind a partially evaluated function to a local component currently, i.e. something like this:
protected ??? someFunc; algorithm someFunc := function someOtherFunc(arg = binding); res := someFunc(...);
This would be nice to have when the same function is used many times in a section, see e.g. BackendDAEOptimize.removeUnusedFunctions.
Change History (3)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
I made an attempt to refine this further, and tried this:
partial function FuncType22<T1, T2, T3, T4> input T1 inArg1; input T2 inArg2; output T3 outArg1; output T4 outArg2; end FuncType22; function FuncID22 input FuncType22 inFunc; output FuncType22 outFunc := inFunc; end FuncID22; function f ... protected FuncType22 func; algorithm func := FuncID22(function someFunction(someArg = arg)); (res1, res2) := func(one_arg); end f;
Unfortunately this doesn't work, because the type of func contains polymorphic types while the call to FuncID22 returns a function with real types, which the compiler doesn't allow. If this would work it would actually be a pretty nice solution I think, since you could just stuff all the needed function signatures and identity functions in e.g. Util. Having to define the specific function signature for the function you want to use is a bit annoying currently.
comment:3 by , 10 years ago
Milestone: | Bootstrapping → 1.9.1 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Fixed in r22758 (parser update).
I came up with a way to do this:
A slightly more natural way of doing this would still be nice to have though.