Page 1 of 1

possible strong mistake using db.sel()

PostPosted: Fri Feb 07, 2020 7:00 pm
by bez
If a variable exists in the GlobalEnvironment and in a DB, when applying db.sel() using this variable the function does not use the variable of the DB but the variable of the GlobalEnvironment. This may cause severe problems...

Re: possible strong mistake using db.sel()

PostPosted: Thu Feb 13, 2020 12:27 pm
by Didier Renard
This is probably a consequence of the "attach" statement that is used only in two functions in RGeostats: i.e.
- db.add for adding variables to a Db
- db.sel for performing selections
The "attach" statement makes it easy to manipulate already existing variables of the Db. As an illustration, imagine the Db (named db) contains two variables called A and B. Then the following command is valid:

db = db.add(db,C=A+B)

But the attach statement actually converts the variables of the Db as if they were variables defined in the environment. This is the reason why problem may occur when similar variables already exist in the environment. I do not know if there is any way distinguish between the two.

With the new naming convention, I am not sure we should not suppress this facility, as we can change the previous statement into:

db = db.create(db,C=db$A+db$B)

Still to be discussed.