Skip to content
This repository has been archived by the owner on Dec 3, 2019. It is now read-only.

probably need to change the behavior of revlanguage when the type of DAG node assigned to a variable changes #123

Open
mtholder opened this issue Mar 3, 2018 · 0 comments

Comments

@mtholder
Copy link
Contributor

mtholder commented Mar 3, 2018

Currently on development (and master), if you create a workspace variable with the = operator, and then reassign it as a constant DAG node, the behavior of the variable is as if it was still a workspace variable.

For example:

> a = 1
> str(a)

   _variable     = x
   _RevType      = Natural
   _value        = 1
   _dagType      = Constant DAG node
   _children     = [  ]

> a <- 1 
> b := exp(a)
> a <- 2
> a
   2
> b
   2.718282
> c <-1
> d := exp(c)
> c <- 2
> d
   7.389056

Note:

  • a is represented as a "Constant DAG node", with no indication that it is a workspace var.
  • applying the <- operator changes the value, but when it binds to a deterministic node (b) it acts like it was workspace variable.
  • this means that reading a variable has side effects such that the results of scripts can vary depending on the order that they are executed.

Solution:

  1. probably should report something in the str to indicate the status is a workspace variable
  2. Either:
    * throw an error when reassigning type to a var (e.g. error on the a <- 1)
    * actually change the status of the node when reassigned.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant