Opened 9 years ago

Last modified 9 years ago

#3564 new enhancement

Allow usage of polymorphic types as functional inputs

Reported by: Per Östlund Owned by: Martin Sjölund
Priority: normal Milestone: Future
Component: MetaModelica Version:
Keywords: Cc:

Description

It would be nice if this would work:

function f1<PF>
  input Real x;
  input PF pf;
  output Real y = pf(x);
end f1;

function f2
  input Real x;
  input Real y = 2.0;
  output Real z = x + y;
end f2;

model test
  Real x = f1(3.0, f2);
end test;

Currently the compiler complains that f1.pf is a component and not a type, but in this case it would be both. Allowing this would remove the need to declare partial functions everywhere when using functions as arguments.

Change History (1)

comment:1 by Martin Sjölund, 9 years ago

The problem is that you get no information about what kind of type PF is. When the type interface is generated, algorithm sections and bindings are removed. So you cannot type-check this when doing separate compilation.

Note: See TracTickets for help on using tickets.