-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Box could have better methods for writing and describing #306
Comments
Hi @jpellegrini, You are right using the name stklos> (define b (box 1 2))
;; b
stklos> b
#[box (2) 7fef4e1352a0]
stklos> (set-box-value! b 0 b)
stklos> b
#[box (2) 7fef4e1352a0]
stklos> This code segfaults on gosh (and on STklos if b uses only one value too). About describe, we can do better, and the next commit will be more detailled: stklos> (define b (box 1 2))
;; b
stklos> (describe b)
#[box (2) 7fcb503042c0] is an instance of class <box>.
It is mutable and contains 2 values.
Its content is:
1
2
stklos> (set-box-value! b 0 b)
stklos> (describe b)
#[box (2) 7fcb503042c0] is an instance of class <box>.
It is mutable and contains 2 values.
Its content is:
#[box (2) 7fcb503042c0]
2 BTW, I'm just asking myself if writing mono-boxes with the |
As required by the issue #306 signaled by @jpellegrini
Hi @egallesio ! |
Yes because circularity can be indirect (a circular list which contains a circular box). stklos> (define l '#0=(1 . #0#))
;; l
stklos> (define b (box l))
;; b
stklos> b
#�=(1 . #0#) but as soon as you do stklos> (set-car! l b) you have a list which contains a box with a circularity. |
Thanks for the explanation @egallesio ! I was thinking more of something like
But even that would be kind of lengthy work I think. |
Writing a box does not show its contents
And describing it doesn't mention it is a box. It also doesn't say if it is mutable or not.
For example, this is what Gauche does:
The text was updated successfully, but these errors were encountered: