
It seems to me that a call to an otherwise pure higher order function is itself pure if all the inputs are also pure, and that there’s nothing else to it. So it should be fairly easy to propagate the purity tag to these calls to. Given that map and friends are all of this sort, wouldn’t there be a benefit to know that such calls may be pure?

Yeah I don’t think it has the bells and whistles you would need/want day-to-day and I’m not versed enough with kabab to add them ;)

@rokitna does KATE have a racket or scheme integration ?

Sent a pull request to improve the documentation for equal?
. Feedback from any and all Racketeers would be appreciated https://github.com/racket/racket/pull/3054

Thanks for the effort!
Some comments: @racket[equals?]
—> @racket[equal?]
on line 17.
I find the original description more directly informative and I would keep it at the top (it’s also example-based which makes it easier for the casual user, and serves as an intuition pump), but your text can still be an additional piece rather than a substitution.
Re. eq?
, The golden rule you mention seems to me to imply that all implementations of equal?
must check for eq?
first, since a program that sometimes relies on eq?
as a cheap substitute for equal?
will break otherwise. But this is nowhere mentioned (and has never been, AFAICT). Is that correct?
“when the infinite unfoldings of the cycles in both values would be equal” I don’t find this informative enough. I would just remove this sentence and replace “this behaviour is the default” in the next sentence with “cycles are automatically dealt with”

- Fixed, thanks!
- Which part of the original description? The definition in terms of
eqv?
, the list of datatypes with further specification ofequal?
, or something else? Or the whole thing? I don’t really see any examples given in the text, it just says “these types do something forequal?
“. It doesn’t say anything about what they do. - Yes, two
eq?
values are alwaysequal?
(that’s implied by the statement on reflexivity). Buteq?
shouldn’t be relied on as a cheap substitute forequal?
unless you know that’s safe for the types you’re working with (like fixnums or interned symbols). Breaking programs that rely on unstated subtleties ofeq?
is a bit like breaking programs that rely onobject-name
- the fault is with the client for expecting more than what the API promises. Don’t useeq?
unless you have a performance issue and you know exactly what you’re doing. - Agreed that “cycles are automatically dealt with” is nice and simple. I thought about writing something like that, but was worried it would be too vague so I chickened out and stuck with the original text’s description of how cycles are compared. If I get more feedback to go with something better here I’ll probably do so.

also, thanks for the review!

Can we reorder it somehow so that contracts, chaperones, and impersonators are mentioned last?

We could. That would entail splitting up the “equals means interchangeable and you can substitute one for the other” text from the “by the way, contracts swap in substitute values all the time” text. Keeping those bits together seems valuable, but the chaperones/contracts/impersonators stuff does read as a bit of a tangent.

For 2.: Yes, the whole thing. The examples I mention are about the types, not about their implementation.

Re. 3.: Then it would be a good idea to guarantee that two eq?
values are always equal?
, possibly even automatically for custom implementations of equal?
(that is, before calling the surrogate equal?
, Racket first checks eq?
in all cases)

:clap: Amazing!

I spent some time reading the FFI docs yesterday, but tbh I’ve never worked with C beyond a “hello world” about 5 years ago.

@notjack Although I agree it wasn’t ideal, here, The Infinite Unfoldings of the Cycles is pretty awesome; it would make a great title for something, someday. :simple_smile:

I think you mean (alarm-evt (+ 1000 (current-inexact-milliseconds))
, which case those are the same, except for the return value on timeout.

I noticed that some packages show a title while being built but most do not: raco setup: 7 making: <pkgs>/automata-lib
raco setup: 6 making: <pkgs>/lindenmayer
raco setup: 5 making: <pkgs>/markparam-lib
raco setup: 4 making: <pkgs>/pfds/pfds (Library of Functional Data Structures in Typed Racket)
raco setup: 3 making: <pkgs>/pict3d/pict3d
raco setup: 2 making: <pkgs>/pict3d/typed
I’m not sure why I’ve never really noticed that before, but I just did. Where does this come from? Although I don’t mind looking in the pfds source to learn, I figured someone might know off the top of their head.

The parenthesized title is the name
field from the collection’s info.rkt
, if it’s present.

@laurent.orseau Yes, the implementation of equal?
starts with eq?
and eqv?
checks.

“Pure if inputs are pure” could be a useful “type”. Currently, there are functions known to be pure independent of arguments, such as list
and vector
, and there ae functions that are pure as long as the arguments known to have a certain “type”, such as +
on numbers and and car
on pairs. So, the kind of generalization you suggest is a “type” in the second category where the constraint on the argument is that same “type”… but then you need a “type” rich enough to track that the right number and “type” of arguments will be supplied to the potentially pure function. Actual type systems are good at that, but absent static types to constrain programs, I would not expect this case to show up often in a way that can be inferred. Of course, I might guess wrong.

Thank you! You reply has pointed me to the flag “-u” which works perfect for me.

Couldn’t a JIT do that though? I’m thinking of things like:
(define proc
(if (eq? 'disp display?)
(lambda (x) (displayln x))
(lambda (x) (void))))
(for-each proc my-list)

In https://docs.racket-lang.org/errortrace/quick-instructions.html, it says: > If your program is a non-module top-level sequence of definitions and expressions, you can instead add > (https://docs.racket-lang.org/reference/require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29\|require errortrace) > > to the beginning of the program I have a program test.rkt
like this: #lang racket
(require errortrace)
(+ 10 "20")
simply running racket test.rkt
doesn’t print any error trace.
Am I misunderstanding the documentation?

I think you missed the “non-module” part.

A tracing JIT would do something interesting there. Otherwise, that still looks to me like too rare of a case (both in pattern and the timing when information would have to become available) for most JITs to bother or succeed. Maybe I’m not seeing the same larger picture that you are.

@capfredf try raco profile test.rkt
instead

(if profiling is what you’re after, which has been my main use-case for errortrace)

I’m really just exploring here, and I would trust your intuition way more than mine in this domain.
It’s just that from time to time I’m thinking of writing such things, hoping that they could be optimized away, but quickly deciding not to since I’m guessing the compiler doesn’t do that.

Thank you @fkingtop. I am writing a daemon, which I start at the command line. Without errortrace
, bugs are hard to locate. For example, if I run my program by racket test.rkt
, I won’t see on which line and column the program goes wrong. So usually, I run my program through racket -l errortrace -t test.rkt

makes sense!

@capfredf The thing about errortrace is that it sets up an eval-handler
that effectively rewrites your original program into one that is more complicated — and therefore supplies better “stack traces”, or profiling info, or whatever. As a result, it’s not really something your program can do to itself (it’s already being evaluated, the eval-handler horse is out of the barn). You can just write a program to do it to other programs. Which is what’s happening with racket -l errortrace __
, or Dr Racket, or Racket Mode.

The most extreme example of this sort of thing is the step-debugger in Dr Racket and Racket Mode. Your original program is annotated i.e. rewritten into a program that is step-debuggable. There are “break?” checks literally written into every little step.

All of these techniques have the drawback that the rewritten version of your program is going to be slower than the original — maybe a little, or a lot, depending on the rewrite.

Oh and the (require errortrace)
in a top-level or REPL: That works because each expression is run through eval
, so changing the eval-handler
will affect subsequent eval
s.

p.s. Trying to explain something is how I see if I’ve managed to halfway learn something. That’s what I’m practicing above. :simple_smile:

For those who use Racket CS, another option to try: set the PLT_CS_DEBUG
envirornment variable. Like errortrace, that affects only newly compiled modules. Unlike errortrace, it doesn’t compile code any differently; it just keeps debugging information, similar to using -g
with gcc
, and the built-in stack trace printer can report locations.
If it turns out to work well, we should make it more accessible or maybe more often the default.

That sounds very cool!

On the one hand I love the idea that anything is possible by rewriting a program, with no special system or hardware support. On the other hand, (equal? possible fast)
is not always #t
.

I should clarify that it’s really a lot like -g
: still approximate and best-effort, unlike errortrace
’s relatively well-defined tracking.

That’s still great, people could use it in production systems to get some narrowing down. Then use errortrace in local dev, including when trying to repro and fix a production failure.


Is there a way for me to eval a string (or load a file) in such a way that the string/file is assumed to be a particular #lang
without the file/string needing to specify it? For example (eval-as-scribble "@defproc[...]{...}")
?

Kate and Notepad++ each come with a syntax highlighting mode for Scheme code. I think it also affects the auto-indentation behavior. I don’t know much about whatever other Racket/Scheme language integration might already exist for these editors.

spacemacs is another way to configure emacs, with many/opinionated default settings and packages. So I’d probably include it under “emacs” for a view-from-orbit chart. But maybe it depends what question you want to answer.

Hi pals! https://exercism.io/\|Exercism is a site to learn language by doing exercise. There is a learning track for https://exercism.io/tracks/racket\|Racket. They are searching Mentor because there is a very large number of student but only 3 mentors. If someone wanna help https://exercism.io/become-a-mentor

paredit
mode for me.


I’m trying the changes out right now with #'racket-repl-buffer-name-project
and it works great!

I see that it defaults to (projectile-project-root-dir)
and falls back to the parent directory of the file. Have you considered having it fall back to (vc-root-dir)
instead?

Racket LONDON meet-up April
Proposed date: Thursday 9th April 1–2pm, - probably at a cafe near St Pancras station. (suggestions appreciated?)
Please let me know if you are interested, even if you can’t confirm attendance. I’ll take the afternoon out of my holiday leave so I can get there.
(If the numbers get too big and I need to book a meeting room I think the best I can get is an hour at http://kingscross.impacthub.net\|kingscross.impacthub.net for £5.70 pp)
It will be casual introductions and chat, though if someone wants to do a short talk or demo that would be most welcome.
Kind regards,
Stephen

I think one thing you could do is appending "#lang" at the front of the string, and then use https://docs.racket-lang.org/read-lang-file/index.html\|https://docs.racket-lang.org/read-lang-file/index.html to get a syntax object, and then eval it

It’s not possible for me during the week before 6pm

I have some solved problems which may be helpful: https://github.com/lojic/LearningRacket/tree/master/exercism.io

@popa.bogdanp Thanks for trying, glad you like it! vc-root-dir
makes sense.