
Thanks!

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.

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

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

Awesome, that shaves off 200ms, thanks!

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 has joined the channel

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

The list is in the sidebar here https://docs.racket-lang.org/reference/index.html

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

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.

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
.

racket/string
pops up a lot for me too

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 require
s for the things you actually use on top of that.

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.

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

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

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

@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!)

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"]))

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

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.

ah that’s pretty neat :slightly_smiling_face:

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

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

(that sounds a little scary though :smile: )

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

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

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.

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

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

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

(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.)

Sorry, I totally missed your main point :( hasheq

@shainohaa has joined the channel

Yep, that is the main point!

@soegaard2 sorry i forgot to respond, yes it did

(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?

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

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

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

ah youre right, its coming from a file im requiring

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

There are many ways to deal with this

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

got it, thank you

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.

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
.