sorawee
2021-10-18 08:08:12

Thanks!


sorawee
2021-10-18 08:10:18

Oh, it just means the keys are not interned symbols, fixnums, or or something like that. Come to think of it, I don’t think it really matters.


laurent.orseau
2021-10-18 09:28:22

racket -e starts in #lang racket it seems. Is it possible to make it start in #lang racket/base instead?


sorawee
2021-10-18 09:31:38

$ racket -l racket/base -e "first" first: undefined $ racket -e "first" #<procedure:first>


laurent.orseau
2021-10-18 09:33:07

Awesome, that shaves off 200ms, thanks!


sorawee
2021-10-18 09:38:21

Actually, there’s also -I, which seems more appropriate. Though If I read correctly, -l would be the same as -I in this case.


alan.delaney
2021-10-18 12:02:04

@alan.delaney has joined the channel


cperivol
2021-10-18 12:43:58

Could you give a couple of examples of useful featres in racket that are not in racket/base?


greg
2021-10-18 12:56:26

greg
2021-10-18 12:57:19

If you mean personally what do people find useful? I use racket/match a lot, as well as racket/format.


greg
2021-10-18 12:58:11

Many things in racket/list are things you could write yourself (e.g. a CS instructor might forbid you to use racket/list :smile:) but are handy to have as correct ready-to-use functions.


greg
2021-10-18 13:00:14

https://docs.racket-lang.org/macro-debugger/index.html#%28mod-path._macro-debugger%2Fanalysis%2Fcheck-requires%29 is handy to take some module and tell you what you’re actually using, including what things from #lang racket.


laurent.orseau
2021-10-18 13:00:31

racket/string pops up a lot for me too


greg
2021-10-18 13:01:01

Racket Mode wraps this in a racket-base-requires command. It will take some file using #lang racket, and change it to use #lang racket/base adding explicit requires for the things you actually use on top of that.


greg
2021-10-18 13:03:02

These days I usually start with #lang racket/base and add requires as needed. But I also know (better than I used to) what modules have what I will need.


greg
2021-10-18 13:03:34

It’s also fine to start with #lang racket, and only later as an “optimization” think about changing to #lang racket/base.


greg
2021-10-18 13:04:09

(Or same for say #lang typed/racket vs. #lang typed/racket/base.)


laurent.orseau
2021-10-18 13:06:34

There’s a “Provided by” quickscript in DrRacket that I use a lot. Makes it very simple to start with #lang racket/base


laurent.orseau
2021-10-18 13:10:31

@greg It’s https://github.com/Metaxal/quickscript-extra/blob/master/scripts/provided-by.rkt\|here. Note that the (require quickscript) does not pull any gui (only racket/base and syntax/parse), so quickscript can be required as normal racket modules. (edit: ah, but the provided-by quickscript itself depends on racket/gui, sorry!)


laurent.orseau
2021-10-18 13:19:04

The racket/gui dependency probably isn’t suitable for racket-mode, but otherwise you could invoke it with this: #lang racket/base (require quickscript-extra/scripts/provided-by racket/class) (define my-ed% (class object% (init-field string) (define/public (get-start-position) 0) (define/public (get-end-position) 0) (define/public (get-backward-sexp start-pos) 0) (define/public (get-forward-sexp start-pos) 0) (define/public (get-text start end) string) (super-new))) (provided-by "" #:editor (new my-ed% [string "string-join"])) (provided-by "" #:editor (new my-ed% [string "first"]))


greg
2021-10-18 13:27:14

Thanks I’ll check it out. I think it might already be covered by https://www.racket-mode.com/#racket_002dadd_002drequire_002dfor_002didentifier


laurent.orseau
2021-10-18 13:27:31

Actually I just remove the dependency on racket/gui in the script. It remains the problem for you that quickscript still depends on drracket though.


laurent.orseau
2021-10-18 13:28:22

ah that’s pretty neat :slightly_smiling_face:


greg
2021-10-18 13:29:24

I should look at hosting quickscripts generally if that’s possible.


laurent.orseau
2021-10-18 13:30:14

maybe we should even try to come up with a common basis, or even some form of interoperability?


laurent.orseau
2021-10-18 13:30:29

(that sounds a little scary though :smile: )


badkins
2021-10-18 14:16:25

@sorawee I’ve never looked into weak references, etc., but I’m curious - why is it impossible to construct the key again?


badkins
2021-10-18 14:20:23

In other words, if I execute (hash-set! hsh "foo" "bar") can’t I simply construct that key with another “foo” ?


greg
2021-10-18 15:19:59

I think one messy part is that various things related to Dr Racket assume a text<%> object, which has a very big surface area, and (IIRC) a dependency on racket/gui. Apart from quickscript, this is baked into drracket:indent, which makes it challenging for custom langs to supply indentation outside Dr Racket. I think probably some non-gui subset of text<%> would need to be defined.


greg
2021-10-18 15:20:12

I started to look at this a year ago and put it on the shelf.


greg
2021-10-18 15:21:31

Honestly I think I hoped that rhombus would result in this needing to be redesigned, assuming it would use the same mechanisms as end-user langs for lexing and indent (#lang racket/base gets special treatment).


greg
2021-10-18 15:22:09

And that would be the opportunity for all the right people to be motivated.


greg
2021-10-18 15:24:14

(For quickscirpt the subset being, the lang’s lexer has run, and so you have access to tokens for things like “forward (s?)-expression” and so on.)


badkins
2021-10-18 15:28:50

Sorry, I totally missed your main point :( hasheq


shainohaa
2021-10-18 18:44:39

@shainohaa has joined the channel


sorawee
2021-10-18 18:58:16

Yep, that is the main point!


a11ce
2021-10-18 21:48:00

@soegaard2 sorry i forgot to respond, yes it did


a11ce
2021-10-18 21:49:28

(magnitude 3+4i) as copied from the docs gives an error: send: target is not an object target: 3+4i method name: get-x how do i fix this?


sorawee
2021-10-18 21:51:10

It doesn’t look like magnitude that you have is from Racket.


sorawee
2021-10-18 21:51:30

Mine can evaluate (magnitude 3+4i) without any error


sorawee
2021-10-18 21:51:53

Can you try running racket -e "(magnitude 3+4i)" in the command line? Do you still see the error?


a11ce
2021-10-18 21:52:08

ah youre right, its coming from a file im requiring


a11ce
2021-10-18 21:52:43

can i specify to use the racket magnitude for that specific call?


sorawee
2021-10-18 21:52:53

There are many ways to deal with this


sorawee
2021-10-18 21:53:36

You can add (require (only-in racket [magniture racket:magnitude])). You can then use racket:magnitude, which is Racket’s magnitude


a11ce
2021-10-18 21:54:00

got it, thank you


sorawee
2021-10-18 21:54:41

Alternatively, if you are not going to use your magnitude, you can (require (except-in <your-module-path> magnitude)). This will require everything from <your-module-path> except magnitude, so magnitude is still Racket’s.


sorawee
2021-10-18 21:55:44

Or alternatively, you can (require (rename-in <your-module-path> [magnitude my:magnitude])). This will make your magnitude available as my:magnitude and Racket’s magnitude is still available as magnitude.