[kepler-dev] referencing nested parameters

Daniel Crawl danielcrawl at gmail.com
Fri Oct 12 17:02:54 PDT 2012


Thanks, Christopher!

x::y works for referencing in non-string parameters.
For string parameters the syntax is $(x::y).

   --dan


On 10/12/12 4:39 PM, Christopher Brooks wrote:
> Hi Dan,
> Try ::
>
> See kepler/ptolemy/src/doc/expressionsa3.htm
>
> Below is the LaTeX.
>
> _Christopher
>> In the context of Ptolemy II models, the variables in scope include
>> all parameters defined at the same level of the hierarchy or
>> higher. So for example, if an actor has a parameter named ``\expr{x}''
>> with
>> value \expr{1.0}, then another parameter of the same actor can have an
>> expression with value ``\expr{PI*x/2.0}'', which will evaluate to
>> $\pi$/2.
>>
>> Consider a parameter \parameter{P} in actor \actorName{X} which is in
>> turn contained by
>> composite actor \actorName{Y}. The scope of an expression for
>> \parameter{P} includes all the
>> parameters contained by \actorName{X} and \actorName{Y}, plus those of
>> the container of \actorName{Y}, its
>> container, etc. That is, the scope includes any parameters defined
>> above in the hierarchy.
>>
>> You can \index{parameters, adding} add parameters to actors (composite
>> or not) by right clicking on the actor, selecting
>>  \submenu{Customize}{Configure} and then clicking on
>> ``\expr{Add},'' or by dragging in a parameter from the
>> \library{Utilities}
>> library. Thus, you can add variables to any scope, a capability that
>> serves the same role as the \index{let} ``let'' construct in many
>> functional programming languages.
>>
>> Occasionally, it is desirable to access parameters that are not in
>> scope. The expression language supports a limited syntax that permits
>> access to certain variables out of scope. In particular, if in place
>> of a variable name \expr{x} in an expression you write \expr{A::x},
>> then instead of looking for \expr{x} in scope, the interpreter looks
>> for a container named \expr{A} in the scope and a parameter named
>> \expr{x} in \expr{A}.  This allows reaching down one level in the
>> hierarchy from either the current container or any of its containers.
>
> On 10/12/12 4:23 PM, Daniel Crawl wrote:
>>
>> Hi Christopher,
>>
>> Is it possible to reference a Parameter contained within another
>> Parameter? For example, if Parameter x contains Parameter y, I
>> expect to access y using x.y with a Const or Expression actor, but
>> this does not work. What do you suggest?
>>
>> Thanks,
>>
>>   --dan
>



More information about the Kepler-dev mailing list