In javascript, scalar values (number, string, boolean and null) are immutable. It means you can't modify the value of a variable, you can only reassign another value to a variable (there's a slight difference). The point is, the v8 tries very hard to keep these immutable as well.
Furthermore, zero-copy can't be done with Javascript variables because they live in the v8-managed memory. The closest thing you can do is to use Buffers in node. Buffers are small JS Objects referring to an allocated memory space outside of the V8-managed memory. If you're gonna do funky stuff with memory, do it with buffers. On Tuesday, 22 April 2014 21:51:11 UTC+2, SimonHF wrote: > > On Tuesday, April 22, 2014 11:28:59 AM UTC-7, mscdex wrote: > >> On Tuesday, April 22, 2014 1:08:44 PM UTC-4, SimonHF wrote: >>> >>> But is it also possible to change the value somehow from C++ land, so >>> that in javascript the variable passed into the function will reflect the >>> changed value? >>> >> >> No. >> > > For example, so far the closest I have got is finding String::MakeExternal > [1] which appears to modify an existing external string, correct? > > And I have a suspicion that it's possible to use external memory with node > buffer. Is this true? And is there example code for this? > > I'm trying to figure out ways to do zero copy between C++ and node / V8. > > [1] > http://izs.me/v8-docs/classv8_1_1String.html#a6419e6b87e73bf03e326dd862fdca495 > > -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
