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

Support closures #4

Open
coolbutuseless opened this issue Sep 7, 2023 · 2 comments
Open

Support closures #4

coolbutuseless opened this issue Sep 7, 2023 · 2 comments

Comments

@coolbutuseless
Copy link
Owner

coolbutuseless commented Sep 7, 2023

plotly internally uses jsonlite to convert objects to JSON, and wants to serialize closures

  • [] figure out what {jsonlite} is doing with closures in general
  • [] figure out what {plotly} is using closures for
  • [] clone it!
@msummersgill
Copy link

Here is the fork I was using to test the POC: https://github.com/msummersgill/plotly/tree/test-yyjsonr

I'm in the same boat as you, not quite sure how or why closures are being converted to JSON, but it definitely gave me a flashback to my early days of learning R and struggling with object of type 'closure' is not subsettable. like everyone else.

@coolbutuseless
Copy link
Owner Author

It appears that plotly is passing a function that returns the data into "toJSON()".

As far as I can tell, this isn't used anywhere.

And by default, jsonlite seems to turn a closure into an array of strings.

 f <- function(x, y, z) { a <- x + y; return(z + a * 2)}
 jsonlite::toJSON(f)
["function (x, y, z) ","{","    a <- x + y","    return(z + a * 2)","}"] 

Not sure this is going anywhere productive...

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

No branches or pull requests

2 participants