importing a cell that depends on viewof / mutable cells

Why is it that when importing a cell that depends on viewof / mutable cells we also have to manually import those cells as well?

E.g., suppose that the cell dependsOnMutable depends on mutable X. Then:

import {dependsOnMutable} from 'remoteNotebook'

won’t work, but

import {dependsOnMutableX, mutable X} from 'remoteNotebook'

and even

import {dependsOnMutableX, X} from 'remoteNotebook'

do work.

There’s a section demonstrating this in the notebook I’ve been compiling on tips and tricks for imports.

2 Likes

That smells like a bug in our import resolution. Looking into it…

1 Like

I have filed a bug for this issue:

This bug has been fixed. Thank you for the excellent bug report, @bgchen!

1 Like

Two related observations.

First, when you import a mutable, you also import its value. So if you say:

import {mutable foo} from "…"

You can now reference both mutable foo and foo. However, if you only import the value:

import {foo} from "…"

Then you can only reference foo; you can’t reference mutable foo.

Second, if you want to alias a mutable during the import, you can say:

import {mutable foo as bar} from "…"

You can now reference mutable bar and bar. The same applies to views.

1 Like