sorawee
2020-8-18 07:22:39

I recall someone (@mflatt?) said that at the time, they thought “private” fields by default make sense, but it becomes clear later that this is a mistake, and Rhombus should/will fix this issue.


notjack
2020-8-18 07:43:05

pretty much what @sorawee said, yeah


notjack
2020-8-18 07:43:37

I’m not really sure transparent / opaque is the right thing to think about in rhombus though


notjack
2020-8-18 07:44:50

the encapsulation of non-transparent structs is a good thing. the bad part is the lack of structural equal+hash and default printing behavior.


notjack
2020-8-18 07:45:41

in my experience, a good default is opaque structs, but with structural equal+hash and a printed representation that prints each field


sorawee
2020-8-18 07:51:45

Another thing I’m slightly annoyed is unreadable values, like #<void> or #<procedure>, cause it screws up read o write = id. Making it readable, but represented by a special struct that says “you can’t rely on the content of this struct” makes much more sense to me.


notjack
2020-8-18 07:52:33

I think read and write are just not good ways to serialize data


wanpeebaw
2020-8-18 09:55:32

I thought structure is a good way to compose and carry data, not a good way to encapsulate.


notjack
2020-8-18 18:31:14

They’re both. That’s kind of what makes them awkward at times. They have a ton of features that don’t matter of you just want to carry data, and the features for encapsulation are a bit awkward because they’re also trying to work for data carriers.


samth
2020-8-18 19:25:58

I think read and write are awesome for serialization, and that encapsulation with transparent printing doesn’t make much sense


notjack
2020-8-18 19:46:18

I don’t think read and write are good because they don’t support user-defined types. I can’t make multisets read-able.


laurent.orseau
2020-8-18 19:48:32

prefab?


laurent.orseau
2020-8-18 19:49:28

I mean: you don’t need the multiset thing to be a prefab, just that you can serialize its values via a prefab


jaz
2020-8-18 19:50:35

but that wouldn’t that satisfy @sorawee’s read o write = id condition


laurent.orseau
2020-8-18 19:51:00

it would, in the prefab. The rest is translation from/to prefab


jaz
2020-8-18 19:51:28

yes, you can round-trip the prefab, but not the actual struct you want to use, right?


laurent.orseau
2020-8-18 19:51:49

yes. Though it shouldn’t be hard to make translators


sorawee
2020-8-18 19:52:07

Oh, actually I didn’t really mean read o write = id.


sorawee
2020-8-18 19:52:18

I mean, read o write shouldn’t error


laurent.orseau
2020-8-18 19:52:25

:smile:


jaz
2020-8-18 19:52:33

well, that’s not hard to satisfy


sorawee
2020-8-18 19:52:44

It makes sense that when #<void> and #<procedure> are there, you are not gonna get id back


laurent.orseau
2020-8-18 19:52:52

read o write = id is a good id though


laurent.orseau
2020-8-18 19:53:27

Shouldn’t #<void> just not be printed at all?


sorawee
2020-8-18 19:53:46

void should not be printed, but it should be writable


laurent.orseau
2020-8-18 19:53:51

(for serialization)


sorawee
2020-8-18 19:54:28

Like, I have (list (void)). If I write this value, what do you expect to happen?


sorawee
2020-8-18 19:54:44

It becomes (list)? That looks weird to me.


laurent.orseau
2020-8-18 19:58:30

Why on earth would you have (list (void)) ? :smile:


laurent.orseau
2020-8-18 19:59:02

Should (list (error "yummy")) be readable after being written?


laurent.orseau
2020-8-18 20:00:40

I’m happy with "#<void> is not readable and breaks everything if you try to read it. Don’t write it anyway.".


laurent.orseau
2020-8-18 20:02:41

Though instead of breaking, it could read the value within a struct unreadable so that #&lt;something&gt; is read as (unreadable 'something) for example.


sorawee
2020-8-18 20:03:14

Yes, that’s exactly what I am proposing


laurent.orseau
2020-8-18 20:03:17

(or opaquerather than unreadable)


laurent.orseau
2020-8-18 20:03:36

Took me a while to come around!


sorawee
2020-8-18 20:10:56

My use case is the following:

When you do some heavy computation, you would want to write the result to a file so that you can subsequently analyze (and not having to run the whole thing again). A part of the result could be these #&lt;void&gt;. But once it’s written, I can’t read them back!

Granted, perhaps it’s a problem with writing. That is, I should be more careful not to write any #&lt;void&gt;, but that’s kinda difficult to control. Perhaps it’s embedded in a data structure that someone else produces, etc.


laurent.orseau
2020-8-18 20:14:59

I was playing the devil’s advocate, I think it makes more sense to be able to read these, as well as opaque struct instances.


laurent.orseau
2020-8-18 20:15:39

Extending the reader to produce an instance of the struct opaque would be nice indeed


soegaard2
2020-8-18 20:25:23

Wait: &gt; (write (list (void))) (#&lt;void&gt;)


soegaard2
2020-8-18 20:29:57

I think the reason #<void> is unreadable is due to Scheme implementations returned void, where the standard said “the result of the expression is unspecified.”.


notjack
2020-8-18 23:47:29

What I mean is that if I have a list or a hash I can just read and write it, but if I have a set, a multiset, or a multidict I can’t without converting it to something else first. And the only reason for that is because the reader knows about lists and hashes and treats them specially.


rokitna
2020-8-18 23:57:03

how automatic do you expect it to be? Racket’s reader can be extended, right?


notjack
2020-8-19 00:17:50

I expect it to work more like serialize and deserialize, which give user defined types the ability to implement support for it


notjack
2020-8-19 00:18:35

I’d like to be able to write some code in the definition of the multiset type that makes all multisets readable and writable.


sorawee
2020-8-19 00:19:41

prefab, cough


notjack
2020-8-19 00:29:56

I have to give up too much to use prefabs


notjack
2020-8-19 00:30:36

• no pretty printing • no invariant guarantees (anyone can shove anything into any field) • can’t implement any struct type properties • can’t control the hash function used for hashing


wanpeebaw
2020-8-19 02:51:46

It make no sense to me that I can’t just print/display the content of a structure while I can access all fields in it with accessor.


sorawee
2020-8-19 03:14:48

Well, perhaps if you don’t provide an accessor to users, then they won’t have accessors to use?


rokitna
2020-8-19 03:14:55

You can if you have the accessors. If the module that defines the structure type doesn’t export its accessors (or its descriptor), then it’s harder to get at that content.


wanpeebaw
2020-8-19 03:28:02

So maybe it should be a property in the module contract? Not structure itself.


wanpeebaw
2020-8-19 03:35:28

Or just let the user decide whether or not to provide the default print function for that structure.