Arc Forumnew | comments | leaders | submit | elibarzilay's commentslogin

Not that it matters much in this context, but racket's equality is extensible:


2 points by akkartik 3416 days ago | link

That is awesome, thanks for the tip.

Now I want to rant about Racket documentation.

You tell me equality is extensible, and now I know that, and I go look at that page and scan it from top to bottom. I do the usual things I do to read stuff online, and I've been pretty successful with my reading, my reading comprehension scores were excellent in standardized tests, I have a phd that was about nothing if not reading opaque publications, and now I'm faced with this page and I still have no idea how to tell that equality is extensible, or how to go about extending it. If you hadn't told me I'd look at that page about booleans and have no reason to expect it to bear the slightest relationship to equality for complex user-defined data structures[1]. Search for 'extensible'. Nope. Oh, 'inspectable structures.' What the sam hill are those? It has to do with prop:equal+hash, which doesn't even look like a single token to my eyes. Is it a function? How do I use it? All this goes through my mind in a flash, and all I feel is stupid.

I keep waiting for the racket reference to gradually become clear, but it's been a year now of poring over it and I don't think it'll ever happen. It's a blind spot, platform nine and three quarters, just around the corner but at ninety degrees from all three dimensions that I can see. I would never ever have noticed that equality is extensible until you told me that was so.

[1] I scan back up and it's right there in the title: "Booleans and equality." See what I mean about feeling stupid? Why should booleans and equality be grouped together? Why should equality be in the section on datatypes and not say structures?


2 points by elibarzilay 3416 days ago | link

0. Note that the actual link is broken -- it's missing a ")" in the end (it's there, but it wasn't included in the url for some reason (I don't know about the local markdown language...))

1. Yes, some of these issues are known, and we're in a constant race with improving the documentation in various ways. As always, emails to the mailing list or bug reports -- or better: suggestions and possibly patches -- all of these are always welcome.

2. In this particular case, I didn't need to guess -- I knew that it was added, so I just needed to find that reference.

3. But if I were trying to find it, the first place I'd look would be the documentation for `equal?' -- and it is indeed there, at the end of the second paragraph.

4. As for how you use this property, the text that I referred to has a link to "Structure Type Properties", which describes all of that.

5. Re the organization -- booleans and equality are grouped because they're related... It also appears as the first subsection in the datatypes chapter, which makes sense there. If you have an idea how to organize it better, then see #1.

6. Yes, it would be nice to have some section that lists all of the properties that could be used for structs. The main problem with doing this is that it's an open system, so anyone can add more properties, but it won't make sense for the core to list properties from modules outside of it. This was discussed recently, and I don't think that anyone had an idea what to do about it.


1 point by akkartik 3416 days ago | link

"if I were trying to find it, the first place I'd look would be the documentation for `equal?' -- and it is indeed there, at the end of the second paragraph."

Part of the problem is that I never tried finding it, because it didn't occur to me that racket would have extensible equal?

A few months ago I was flattened - absolutely flattened - to find out that PLT has optional args and keyword args. (

I have no idea why this is. Perhaps the problem is that people expect scheme to be a small language.


3 points by elibarzilay 3416 days ago | link

Well, the optionals and keyword arguments have been in for a long time now... In fact, the current thing is a second iteration after a first facility that was more CL-like...

In any case, Racket is certainly not a small language...


1 point by akkartik 3416 days ago | link

Yes, as I was ranting I was feeling bad for not having contributed to improve things. I wasn't being rhetorical about feeling stupid and guilty. Lack of understanding is a barrier but no excuse. For me to say "I have a phd, but this I can't read" is akin to saying "I've learned spanish, but chinese is hard." Well, d'uh. Deal.

Perhaps PLT needs a user guide in addition to a reference, a level of redundancy with a kinda orthogonal organization (focusing on complex tasks involving multiple advanced concepts) that'll help people triangulate on understanding, or just use what works for them.


3 points by elibarzilay 3416 days ago | link

Heh, excellent idea:

(See also other such documents at


1 point by akkartik 3415 days ago | link

I've seen that before. Why have I not paid more attention?

Here's the extremely clear guide on extensible equality:

I'm going to withdraw my rant. It's something specific about my stupidity that's causing me these problems. Still investigating.

Ah, I think I see what's been happening. Since I started out with arc I've restricted myself to the mzscheme 'ghetto' and not paid as much attention to the racket language itself. My attitude was "who knows what works in mzscheme and what doesn't." This has been the root cause of my troubles, I think.

I'm going to focus on core racket now.


2 points by evanrmurphy 3416 days ago | link

Thanks for the link to Guide: Racket. I've also had trouble getting into Racket's documentation, but this looks like a much more accessible starting point than Reference: Racket.


1 point by rocketnia 3415 days ago | link

(Fixed link: ( I fixed it by putting another pair of parentheses around it to fool the regex. :-p )

Oh, awesome. At one point I think I knew that, too, but at some point I saw 'make-custom-hash ( and forgot about it.

Given that prop:equal+hash exists, are there any commonly used convenience macros for implementing it for a structure? It's niftiest if they support cyclic structures too, since Racket's equality API makes that possible, but I'm not picky. ^_^ I'll probably just write something myself either way, but I'm on the lookout for inspiration.


2 points by elibarzilay 3439 days ago | link | parent | on: Arc run error - beginner

Note that Racket has readline support:


1 point by waterhouse 3439 days ago | link

Unfortunately, it doesn't do paren- or quote-matching, and it doesn't interact well with the current arc> prompt.

  $ racket -il readline -f as.scm
  Welcome to Racket v5.0.2.
  Use (quit) to quit, (tl) to return here after an interrupt.
  (+ 1 2)
With access to the underlying Racket, one can (require readline/readline) and do (readline "arc> ") to get the proper prompt, but a) this requires redoing the Arc REPL, either by hacking (tl) in ac.scm or by writing something like (while t (prn:eval:read ($.readline "arc> "))), and b) it still doesn't do the matching, which I find an important feature.


3 points by elibarzilay 3439 days ago | link

Not much to do about the prompt -- racket needs to know how wide the prompt which is why that argument is there.

But the paren matching is definitely possible -- I have "set blink-matching-paren on" in my ~/.inputrc file, and never had any problems with it.

BTW, another advantage of using the racket readline facility is that it's possible to do completion for the toplevel namespace.


3 points by elibarzilay 3439 days ago | link | parent | on: Arc run error - beginner

That fix is also in 5.0.2.


1 point by akkartik 3439 days ago | link

That was quick! Upgraded.


2 points by elibarzilay 3664 days ago | link | parent | on: What does ac buy us?

You can do all of these as macros (etc) rather than a compiler. For example, an `fn' macro would inspect the body and plant `nil' return values; for arbitrary `='s see swindle's `setf!', the convenient indexing is easily done with generalized functions, rest notation and destructuring also exist in plt and would be easy to incorporate. The difficulties lie more in the subtle points: for example, plt macros have phase separation, and arc is more lispish with a single phase for everything -- and doing that would be very difficult at best. As another example, mutable cons pairs are hacked onto arc (when using the newer plt versions) in a way that works out because arc is essentially serializing its own lists -- but if you use more plt-isms, and end up using more consed lists, you are more likely to run into problems with stepping over the plt assumption of pairs being immutable.


Fexprs are very different from macros. Not having them is considered by most people as a feature, not a wart. In fact, the common approach to fexprs is a wart. One implication is that eval, as implemented in MzScheme and in Arc is doing the right thing. (And macros are much more well behaved than fexprs, which keeps the language sane.)


1 point by akkartik 3727 days ago | link

I don't follow. Are modern lisps not using f-exprs?

If so I have been imprecise. I was using Alan Kays quote to refer to lisp's special-forms and their many rules on what gets evaluated in what position when.


2 points by elibarzilay 3725 days ago | link

No, modern lisps don't do that. (Except maybe for newlisp, which does what you'd call "the right thing" with `eval`, and even encourages doing so; but this goes with the fact that it throws lexical scope out the window.)

As for the quote, it depends on how you view it. You can take it anywhere to proper criticism of fexprs (which has become the popular view since then), or you can take it as criticizing the fact that special forms are needed, or if you squint hard enough, you can say that it's advocating a language like Haskell. Considering the first two options, I think that the first one (criticism of fexprs) is very explicit, the second one is less likely.

In any case, trying to get an `eval` that works with lexical scope is related to fexprs. So the feature that you want is one that Kay criticizes.


1 point by elibarzilay 3738 days ago | link | parent | on: Bug in atomic when using kill-thread

The documentation server is back up.


1 point by akkartik 3738 days ago | link

Still down for me, but from google's cache:

"Terminates the specified thread immediately, or suspends the thread if thd was created with thread/suspend-to-kill."

So it seems kill-thread is guaranteed to kill the thread by the time it returns.


1 point by akkartik 3737 days ago | link

Oh, but break-thread is not: "Registers a break with the specified thread." "When a break is detected and enabled, the exn:break exception is raised in the thread sometime afterward"


No fork is necessary for mutable pairs -- mzscheme is flexible enough to allow breaking itself...


1 point by CatDancer 3930 days ago | link

I tried a port ( but it's running 3.5 times slower... any suggestions?


There are a lot of new features, as well as more and better optimizations in v4.2.


1 point by elibarzilay 3977 days ago | link | parent | on: A fix for arc's gensyms

You could come up with a new "subtype" of symbols which is reserved for gensymed symbols -- then use some mapping of unique names for new such gensyms (say, a counter), and then use some new syntax like `__name' to evaluate to these things (assuming that you want code to be able to write such gensyms literally)...

But doing all of that is equivalent to just creating gensyms as done now, with a `__' prefix -- so if you really want that last property then nothing needs to be changed (perhaps only the `gs' prefix)...


Well, custodians are not really a workaround -- they're intended just for situations where you want to close up all resources that belong to a server thread, for example.

But in any case, I don't know about such a leak... AFAIK, if you're closing the port, then everything should work properly. Is there some example code that shows the problem? (Better to mail me, btw, since keeping track of this thing is difficult and there's no email alerts...)


1 point by pg 3975 days ago | link

We're ok now. Rtm figured out how to get the custodian stuff down into ac.scm, so in Arc code this stuff "just works."