Page 1 of 1

[SOLVED] Problem with operator "<-" for the model-class

PostPosted: Mon Sep 16, 2013 4:00 pm
by Nicolas Desassis
In the model-class documentation, we can read :
"
[<-

model[i]<-value copies the contents of the value into the i-th basic structure of the model-class
"

When I try the following sequence

mdlt<-model.create(melem.name(2),ndim=2) #Creation of a first model
mdlt<-model.create(melem.name(3),ndim=2,model=mdlt) #Append a second model
value<-model.create(melem.name(4),ndim=2) #Creation of a third model
mdlt[1]<-value #use of the assignment operator
mdlt


R closes and with the following message

terminate called after throwing an instance of 'Rcpp::no_such_slot'
what(): no such slot

Re: Problem with operator "<-" for the model-class

PostPosted: Mon Sep 16, 2013 7:29 pm
by Didier Renard
Dear Nicolas

You probably remember that you model object (mdlt) is composed as the union of basic structures (called "melem").
Therefore, the last sentence:

mdlt[1] <- value

does not make sense as "value" is the result of model.init() and is therefore a model, not a melem.

Instead, you could have done:
value <- melem.init()
mdlt[1] <- value

This would have been meaningfull.

Nevertheless I added the missing safety control to the mentionned operator. It will e active in the next published version (9.1.7)

Re: Problem with operator "<-" for the model-class

PostPosted: Mon Sep 16, 2013 7:51 pm
by Nicolas Desassis
Dear Didier,

thank for your explanations. It is very clear.
I had missed the function melem.init and the fact that melem-class can be instantiated with melem.init.

Nicolas