laurent.orseau
2020-2-24 08:26:18

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?


chris613
2020-2-24 09:53:20

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 ;)


spdegabrielle
2020-2-24 10:06:18

@rokitna does KATE have a racket or scheme integration ?


notjack
2020-2-24 10:15:48

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


laurent.orseau
2020-2-24 10:43:46

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”


notjack
2020-2-24 11:12:43
  1. Fixed, thanks!
  2. Which part of the original description? The definition in terms of eqv?, the list of datatypes with further specification of equal?, 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 for equal?“. It doesn’t say anything about what they do.
  3. Yes, two eq? values are always equal? (that’s implied by the statement on reflexivity). But eq? shouldn’t be relied on as a cheap substitute for equal? 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 of eq? is a bit like breaking programs that rely on object-name - the fault is with the client for expecting more than what the API promises. Don’t use eq? unless you have a performance issue and you know exactly what you’re doing.
  4. 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.

notjack
2020-2-24 11:12:53

also, thanks for the review!


sorawee
2020-2-24 11:14:59

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


notjack
2020-2-24 11:17:37

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.


laurent.orseau
2020-2-24 11:23:29

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


laurent.orseau
2020-2-24 11:32:44

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)


d_run
2020-2-24 11:51:01

:clap: Amazing!


d_run
2020-2-24 11:52:51

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.


greg
2020-2-24 13:09:04

@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:


mflatt
2020-2-24 13:16:33

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


greg
2020-2-24 13:22:32

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.


mflatt
2020-2-24 13:26:25

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


mflatt
2020-2-24 13:27:58

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


mflatt
2020-2-24 13:40:52

“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.


capfredf
2020-2-24 13:42:17

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


laurent.orseau
2020-2-24 13:48:22

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)


capfredf
2020-2-24 13:48:47

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?


mflatt
2020-2-24 13:51:37

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


mflatt
2020-2-24 13:57:04

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.


laurent.orseau
2020-2-24 13:57:33

@capfredf try raco profile test.rkt instead


laurent.orseau
2020-2-24 13:58:35

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


laurent.orseau
2020-2-24 14:07:01

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.


capfredf
2020-2-24 14:08:51

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


laurent.orseau
2020-2-24 14:10:40

makes sense!


greg
2020-2-24 14:24:47

@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.


greg
2020-2-24 14:25:53

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.


greg
2020-2-24 14:26:27

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.


greg
2020-2-24 14:28:23

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 evals.


greg
2020-2-24 14:30:00

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:


mflatt
2020-2-24 14:31:06

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.


greg
2020-2-24 14:32:40

That sounds very cool!


greg
2020-2-24 14:34:31

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.


mflatt
2020-2-24 14:35:02

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


greg
2020-2-24 14:37:20

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.



massung
2020-2-24 17:34:00

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[...]{...}") ?


rokitna
2020-2-24 17:53:38

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.


greg
2020-2-24 18:48:04

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.


acciaiodigitale
2020-2-24 18:56:46

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


krismicinski
2020-2-24 19:13:36

paredit mode for me.



popa.bogdanp
2020-2-24 20:57:11

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


popa.bogdanp
2020-2-24 21:00:59

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?


spdegabrielle
2020-2-24 21:50:26

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


sorawee
2020-2-24 21:50:45

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


acciaiodigitale
2020-2-24 22:00:16

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


badkins
2020-2-24 23:47:10

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


greg
2020-2-25 03:41:54

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