Re: [racket-users] Are function parameters copy on write?

2019-06-06 Thread David Storrs
Cool.  Thanks, Jay.

On Thu, Jun 6, 2019 at 12:25 PM Jay McCarthy  wrote:

> On Thu, Jun 6, 2019 at 12:16 PM David Storrs 
> wrote:
>
>>
>>
>> On Thu, Jun 6, 2019 at 12:14 PM Jay McCarthy 
>> wrote:
>>
>>> Your code is passing bytes by value, but bytes are themselves
>>> pointers, so you are passing copies of the pointer, not copies of the
>>> bytes. When you modify it, with `bytes-set!` you are modifying the
>>> underlying structure. When you copy it with `subbytes` or
>>> `bytes-copy`, you are making a new object with a new pointer.
>>>
>>
>> Sweet, that's what I needed to know.  Thank you.
>>
>> What about other things, like arbitrary structs, (im)mutable strings,
>> hashes, etc?
>>
>
> Everything is like this except word sized objects like numbers but those
> are not mutable so you’d never know the difference (performance would be
> same too because the pointer would be word sized anyways.)
>
>
>>
>>
>>> --
>>> Jay McCarthy
>>> Associate Professor @ CS @ UMass Lowell
>>> http://jeapostrophe.github.io
>>> Vincit qui se vincit.
>>>
>>> On Thu, Jun 6, 2019 at 12:00 PM David Storrs 
>>> wrote:
>>> >
>>> > My understanding is that Racket is call by value, not call by
>>> reference.  My application will often be passing around large-ish byte
>>> strings; will they be copied every time I pass them, or will the
>>> interpreter use copy-on-write?
>>> >
>>> > --
>>> > You received this message because you are subscribed to the Google
>>> Groups "Racket Users" group.
>>> > To unsubscribe from this group and stop receiving emails from it, send
>>> an email to racket-users+unsubscr...@googlegroups.com.
>>> > To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/racket-users/CAE8gKod0Z%2Bv-3Oew4mPhsT4mwzOLdhc7Q-nF4xf_yH3qAgq_Hg%40mail.gmail.com
>>> .
>>> > For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to racket-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/CAE8gKodNrutKxDivmbpH7Pz_Y1Hg0BfiavQagVToYdm%2BHsr-%3DQ%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
>
> --
> Jay McCarthy
> Associate Professor @ CS @ UMass Lowell
> http://jeapostrophe.github.io
> Vincit qui se vincit.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAE8gKocmn7W-GQoeEtrTKy_vN-7c2vfinT8tQ%3DTr0dvYEkM%3DBg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Are function parameters copy on write?

2019-06-06 Thread Jay McCarthy
On Thu, Jun 6, 2019 at 12:16 PM David Storrs  wrote:

>
>
> On Thu, Jun 6, 2019 at 12:14 PM Jay McCarthy 
> wrote:
>
>> Your code is passing bytes by value, but bytes are themselves
>> pointers, so you are passing copies of the pointer, not copies of the
>> bytes. When you modify it, with `bytes-set!` you are modifying the
>> underlying structure. When you copy it with `subbytes` or
>> `bytes-copy`, you are making a new object with a new pointer.
>>
>
> Sweet, that's what I needed to know.  Thank you.
>
> What about other things, like arbitrary structs, (im)mutable strings,
> hashes, etc?
>

Everything is like this except word sized objects like numbers but those
are not mutable so you’d never know the difference (performance would be
same too because the pointer would be word sized anyways.)


>
>
>> --
>> Jay McCarthy
>> Associate Professor @ CS @ UMass Lowell
>> http://jeapostrophe.github.io
>> Vincit qui se vincit.
>>
>> On Thu, Jun 6, 2019 at 12:00 PM David Storrs 
>> wrote:
>> >
>> > My understanding is that Racket is call by value, not call by
>> reference.  My application will often be passing around large-ish byte
>> strings; will they be copied every time I pass them, or will the
>> interpreter use copy-on-write?
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups "Racket Users" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> an email to racket-users+unsubscr...@googlegroups.com.
>> > To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/CAE8gKod0Z%2Bv-3Oew4mPhsT4mwzOLdhc7Q-nF4xf_yH3qAgq_Hg%40mail.gmail.com
>> .
>> > For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAE8gKodNrutKxDivmbpH7Pz_Y1Hg0BfiavQagVToYdm%2BHsr-%3DQ%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
-- 

--
Jay McCarthy
Associate Professor @ CS @ UMass Lowell
http://jeapostrophe.github.io
Vincit qui se vincit.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAJYbDa%3DEF0BxMKeGy%2BVCB9iM7Rit-i%3Dy%3DfXFNpQK3Xbw7NKR3g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Are function parameters copy on write?

2019-06-06 Thread David Storrs
On Thu, Jun 6, 2019 at 12:14 PM Jay McCarthy  wrote:

> Your code is passing bytes by value, but bytes are themselves
> pointers, so you are passing copies of the pointer, not copies of the
> bytes. When you modify it, with `bytes-set!` you are modifying the
> underlying structure. When you copy it with `subbytes` or
> `bytes-copy`, you are making a new object with a new pointer.
>

Sweet, that's what I needed to know.  Thank you.

What about other things, like arbitrary structs, (im)mutable strings,
hashes, etc?


> --
> Jay McCarthy
> Associate Professor @ CS @ UMass Lowell
> http://jeapostrophe.github.io
> Vincit qui se vincit.
>
> On Thu, Jun 6, 2019 at 12:00 PM David Storrs 
> wrote:
> >
> > My understanding is that Racket is call by value, not call by
> reference.  My application will often be passing around large-ish byte
> strings; will they be copied every time I pass them, or will the
> interpreter use copy-on-write?
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com.
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAE8gKod0Z%2Bv-3Oew4mPhsT4mwzOLdhc7Q-nF4xf_yH3qAgq_Hg%40mail.gmail.com
> .
> > For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAE8gKodNrutKxDivmbpH7Pz_Y1Hg0BfiavQagVToYdm%2BHsr-%3DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Are function parameters copy on write?

2019-06-06 Thread Jay McCarthy
Your code is passing bytes by value, but bytes are themselves
pointers, so you are passing copies of the pointer, not copies of the
bytes. When you modify it, with `bytes-set!` you are modifying the
underlying structure. When you copy it with `subbytes` or
`bytes-copy`, you are making a new object with a new pointer.

--
Jay McCarthy
Associate Professor @ CS @ UMass Lowell
http://jeapostrophe.github.io
Vincit qui se vincit.

On Thu, Jun 6, 2019 at 12:00 PM David Storrs  wrote:
>
> My understanding is that Racket is call by value, not call by reference.  My 
> application will often be passing around large-ish byte strings; will they be 
> copied every time I pass them, or will the interpreter use copy-on-write?
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/CAE8gKod0Z%2Bv-3Oew4mPhsT4mwzOLdhc7Q-nF4xf_yH3qAgq_Hg%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAJYbDam4SpLL-vt0q78NpqT_GbxVeLhxkN_UWKB%3DTsKz2zsE%2BA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Are function parameters copy on write?

2019-06-06 Thread Jon Zeppieri
On Thu, Jun 6, 2019 at 12:00 PM David Storrs  wrote:

> My understanding is that Racket is call by value, not call by reference.
> My application will often be passing around large-ish byte strings; will
> they be copied every time I pass them, or will the interpreter use
> copy-on-write?
>


"call-by-value" is used in two very different ways. Racket is call-by-value
in the sense that all arguments to functions need to be evaluated before
the function body is evaluated. This kind of "call-by-value" is
distinguished from other evaluation strategies, like call-by-name or
call-by-need.

The other sense of the term -- and the one you're asking about -- has to do
with whether arguments are copied from caller to callee. I find the terms
"call-by-value" and "call-by-reference" in this context to be pretty
confusing. (If the function argument in question is a mutable byte-string,
why wouldn't passing it "by-value" imply that you pass the very same
mutable byte-string, rather than making a copy of it?) At any rate, Racket
does not copy arguments on function calls (except insofar as the copy is
indistinguishable from the original -- as with a fixnum, for example).

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAKfDxxx8TxKvuASFRgNd8A205LvdEFzggG-BN7o8ocRN5pk%2BvQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Are function parameters copy on write?

2019-06-06 Thread David Storrs
My understanding is that Racket is call by value, not call by reference.
My application will often be passing around large-ish byte strings; will
they be copied every time I pass them, or will the interpreter use
copy-on-write?

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAE8gKod0Z%2Bv-3Oew4mPhsT4mwzOLdhc7Q-nF4xf_yH3qAgq_Hg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.