[racket] serialization of math/array

From: Sam Tobin-Hochstadt (samth at cs.indiana.edu)
Date: Wed Jul 23 12:00:35 EDT 2014

De-serializing an array of numbers and then passing it to typed code
would produce a wrapper, not a first-order check, and so would be very
expensive.

What you want is something that can tell that the untyped reference is
dead after value is passed to typed code, so that a first-order check
can be used. This would require something new from Racket in the form
of a revocable reference.

Sam

On Wed, Jul 23, 2014 at 11:52 AM, Matthias Felleisen
<matthias at ccs.neu.edu> wrote:
>
> Let's assume we serialize arrays of numbers, which is what I assume the background to the question is. In that case, the answer isn't all that obvious to me.
>
>
>
>
> On Jul 23, 2014, at 11:47 AM, Sam Tobin-Hochstadt <samth at cs.indiana.edu> wrote:
>
>> That really depends what the contracts are, and if they're first-order.
>>
>> Sam
>>
>> On Wed, Jul 23, 2014 at 11:45 AM, Matthias Felleisen
>> <matthias at ccs.neu.edu> wrote:
>>>
>>> Will these costs dominate the cost of I/O here?
>>>
>>>
>>> On Jul 23, 2014, at 11:37 AM, Sam Tobin-Hochstadt <samth at cs.indiana.edu> wrote:
>>>
>>>> Unfortunately, I think that strategy would incur substantial overhead
>>>> for things like serialization of large arrays.
>>>>
>>>> Sam
>>>>
>>>> On Wed, Jul 23, 2014 at 11:28 AM, Matthias Felleisen
>>>> <matthias at ccs.neu.edu> wrote:
>>>>>
>>>>> On Jul 23, 2014, at 11:10 AM, Neil Toronto <neil.toronto at gmail.com> wrote:
>>>>>
>>>>>> On 07/16/2014 10:25 AM, Berthold Bäuml wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> will there be serialization support for math/array and math/matrix in the near future? As far as I understand in principle it should be possible at leas in  a straight forward way as there are  already the routines array->list and list->array.
>>>>>>
>>>>>> Sorry it's taken so long to reply. Part of the problem is that `racket/serialize` isn't typed:
>>>>>>
>>>>>> #lang typed/racket
>>>>>>
>>>>>>> (require racket/serialize)
>>>>>>> serialize
>>>>>> Type Checker: missing type for identifier;
>>>>>> consider using `require/typed' to import it
>>>>>> identifier: serialize
>>>>>> from module: racket/serialize in: serialize
>>>>>>
>>>>>>
>>>>>> This and the fact that the array struct types are declared in Typed Racket makes adding serialization tricky at best. Also, it would only work in untyped Racket.
>>>>>>
>>>>>> Generally, deserializing is hard to make type-safe, and nobody has taken it up yet for Typed Racket. Occurrence typing should help, but would require `deserialize` to take a predicate argument (like the second argument to `list*->array`), which it currently doesn't do.
>>>>>
>>>>>
>>>>> Lucky us. I often leave the I/O parts of my programs untyped (I write either highly imprecise unchecked signatures or I don't provide types).
>>>>> ____________________
>>>>> Racket Users list:
>>>>> http://lists.racket-lang.org/users
>>>
>


Posted on the users mailing list.