{"category":{"__v":2,"_id":"566e55c12c1e760d0030c56d","pages":["566e55c12c1e760d0030c56e","566e55c12c1e760d0030c56f","566e55c12c1e760d0030c570","566e55c12c1e760d0030c571","566e55c12c1e760d0030c572","566e55c12c1e760d0030c573","566e55c12c1e760d0030c574","566e55c12c1e760d0030c575","566e55c12c1e760d0030c576","566e55c12c1e760d0030c577","566e55c12c1e760d0030c578","566e55c12c1e760d0030c579","566e55c12c1e760d0030c57a","566e55c12c1e760d0030c57b","566e55c12c1e760d0030c57c","566e55c12c1e760d0030c57d","566e55c12c1e760d0030c57e","566e55c12c1e760d0030c57f","566e55c12c1e760d0030c580","566e55c12c1e760d0030c581","566e55c12c1e760d0030c582","566e55c12c1e760d0030c583","566e55c12c1e760d0030c584","566e55c12c1e760d0030c585","566e55c12c1e760d0030c586","566e55c12c1e760d0030c587","566e55c12c1e760d0030c588","566e5640c15c8f0d000ee863"],"project":"54408e54309354080070a896","version":"566e55c02c1e760d0030c56c","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-10-17T03:34:44.886Z","from_sync":false,"order":0,"slug":"documentation","title":"Documentation"},"project":"54408e54309354080070a896","user":"544083bee239230800071bef","version":{"__v":1,"_id":"566e55c02c1e760d0030c56c","project":"54408e54309354080070a896","createdAt":"2015-12-14T05:38:08.400Z","releaseDate":"2015-12-14T05:38:08.400Z","categories":["566e55c12c1e760d0030c56d"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.2.3","version":"1.2.3"},"_id":"566e55c12c1e760d0030c574","__v":0,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2014-12-15T04:41:58.386Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":6,"body":"#Motivation \nThe type **JRef** was created to support return of a Julia expression of any type beyond basic types without having to map that type to an equivalent Javascript type.  The task of establishing such a mapping is still an objective, however, and will build off this start.  In the mean time, this offers a simple way to connect Julia functionality that produces values of non basic types to Javascript variables and then subsequently use those variables as input.\n\n# Gain of Efficiency\nAs an added benefit, since JRefs are just wrappers for the corresponding Julia values, the need for introspection and subsequent instantiation of the corresponding Javascript value is avoided. Likewise the need to re-evaluate and convert back to Julia from Javascript when a JRef is used as input is also avoided.\n\n# Example\nFor example assuming that the Julia package [RDataSets](https://github.com/johnmyleswhite/RDatasets.jl) is installed using that standard package manager \n\n    julia> Pkg.add(\"RDatasets\")\n\nThen as per the example given in the RDataSet README, a new *dataset* value can be created and exported as a **JRef**, and then subsequently  used as input to string.  \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var julia = require('node-julia');\\nvar d;\\n\\njulia.eval('using RDatasets');\\nd = julia.eval('dataset(\\\"boot\\\",\\\"neuro\\\")');\\nconsole.log(julia.exec('string',d));\\n\",\n      \"language\": \"julia\"\n    }\n  ]\n}\n[/block]\n    \nThe output of string is then printed to the console\n\n    469x6 DataFrames.DataFrame\n    | Row | V1     | V2     | V3     | V4   | V5    | V6    |\n    |-----|--------|--------|--------|------|-------|-------|\n    | 1   | NA     | -203.7 | -84.1  | 18.5 | NA    | NA    |\n    | 2   | NA     | -203.0 | -97.8  | 25.8 | 134.7 | NA    |\n    | 3   | NA     | -249.0 | -92.1  | 27.8 | 177.1 | NA    |\n    | 4   | NA     | -231.5 | -97.5  | 27.0 | 150.3 | NA    |\n    | 5   | NA     | NA     | -130.1 | 25.8 | 160.0 | NA    |\n    | 6   | NA     | -223.1 | -70.7  | 62.1 | 197.5 | NA    |\n    | 7   | NA     | -164.8 | -12.2  | 76.8 | 202.8 | NA    |\n    | 8   | NA     | -221.6 | -81.9  | 27.5 | 144.5 | NA    |\n    ⋮\n    | 461 | NA     | -163.2 | -43.6  | 69.5 | 173.9 | NA    |\n    | 462 | NA     | -207.3 | -88.3  | 9.6  | 104.1 | 218.0 |\n    | 463 | -242.6 | -142.0 | -21.8  | 69.8 | 148.7 | NA    |\n    | 464 | -235.9 | -128.8 | -33.1  | 68.8 | 177.1 | NA    |\n    | 465 | NA     | -140.8 | -38.7  | 58.1 | 186.3 | NA    |\n    | 466 | NA     | -149.5 | -40.3  | 62.8 | 139.7 | 242.5 |\n    | 467 | -247.6 | -157.8 | -53.3  | 28.3 | 122.9 | 227.6 |\n    | 468 | NA     | -154.9 | -50.8  | 28.1 | 119.9 | 201.1 |\n    | 469 | NA     | -180.7 | -70.9  | 33.7 | 114.8 | 222.5 |","excerpt":"","slug":"jref","type":"basic","title":"JRef"}
#Motivation The type **JRef** was created to support return of a Julia expression of any type beyond basic types without having to map that type to an equivalent Javascript type. The task of establishing such a mapping is still an objective, however, and will build off this start. In the mean time, this offers a simple way to connect Julia functionality that produces values of non basic types to Javascript variables and then subsequently use those variables as input. # Gain of Efficiency As an added benefit, since JRefs are just wrappers for the corresponding Julia values, the need for introspection and subsequent instantiation of the corresponding Javascript value is avoided. Likewise the need to re-evaluate and convert back to Julia from Javascript when a JRef is used as input is also avoided. # Example For example assuming that the Julia package [RDataSets](https://github.com/johnmyleswhite/RDatasets.jl) is installed using that standard package manager julia> Pkg.add("RDatasets") Then as per the example given in the RDataSet README, a new *dataset* value can be created and exported as a **JRef**, and then subsequently used as input to string. [block:code] { "codes": [ { "code": "var julia = require('node-julia');\nvar d;\n\njulia.eval('using RDatasets');\nd = julia.eval('dataset(\"boot\",\"neuro\")');\nconsole.log(julia.exec('string',d));\n", "language": "julia" } ] } [/block] The output of string is then printed to the console 469x6 DataFrames.DataFrame | Row | V1 | V2 | V3 | V4 | V5 | V6 | |-----|--------|--------|--------|------|-------|-------| | 1 | NA | -203.7 | -84.1 | 18.5 | NA | NA | | 2 | NA | -203.0 | -97.8 | 25.8 | 134.7 | NA | | 3 | NA | -249.0 | -92.1 | 27.8 | 177.1 | NA | | 4 | NA | -231.5 | -97.5 | 27.0 | 150.3 | NA | | 5 | NA | NA | -130.1 | 25.8 | 160.0 | NA | | 6 | NA | -223.1 | -70.7 | 62.1 | 197.5 | NA | | 7 | NA | -164.8 | -12.2 | 76.8 | 202.8 | NA | | 8 | NA | -221.6 | -81.9 | 27.5 | 144.5 | NA | ⋮ | 461 | NA | -163.2 | -43.6 | 69.5 | 173.9 | NA | | 462 | NA | -207.3 | -88.3 | 9.6 | 104.1 | 218.0 | | 463 | -242.6 | -142.0 | -21.8 | 69.8 | 148.7 | NA | | 464 | -235.9 | -128.8 | -33.1 | 68.8 | 177.1 | NA | | 465 | NA | -140.8 | -38.7 | 58.1 | 186.3 | NA | | 466 | NA | -149.5 | -40.3 | 62.8 | 139.7 | 242.5 | | 467 | -247.6 | -157.8 | -53.3 | 28.3 | 122.9 | 227.6 | | 468 | NA | -154.9 | -50.8 | 28.1 | 119.9 | 201.1 | | 469 | NA | -180.7 | -70.9 | 33.7 | 114.8 | 222.5 |