Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for peers names as string variables #249

Open
wants to merge 1 commit into
base: toolchain-2.9
Choose a base branch
from

Conversation

ahoarau
Copy link
Contributor

@ahoarau ahoarau commented Dec 7, 2017

This PR allows to write scripts as :

var string comp_name = "hello"
loadComponent(comp_name,"OCL::HelloWorld")
comp_name.configure()
comp_name.start()

The commented cout returns : Peer as string variable comp_name --> hello

This allows to write scripts as :
var string comp_name = "hello"
loadComponent(comp_name,"OCL::HelloWorld")
comp_name.configure()
@meyerj
Copy link
Member

meyerj commented Jan 3, 2018

See also my comment in #149 (comment) with an alternative proposal to solve the problem.

I do not like the implicit conversion from string variables to a peer very much and would suggest the opposite approach, namely to return a TaskContext * from loadComponent(). As a result, your example would have to be written like

var string comp_name = "hello"
var TaskContext comp = loadComponent(comp_name,"OCL::HelloWorld")
comp.configure()
comp.start()

with a clear separation between the actual component (comp) and its name (comp_name). Additionally, each TaskContext could expose getPeer(string name) as an operation to convert from names to actual TaskContext instances explicitly.

Implicit conversion from TaskContext to string or vice-versa as originally proposed in #149 (comment) might not even be required if the PeerParser handles variables of type TaskContext in the same way as peers, so that names of peers and variables pointing to TaskContexts can be used interchangeably in scripting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants