alexharsanyi
2021-6-17 07:56:46

It seems that has-focus? always returns #f. Here is an example which involves just the call to has-focus?

#lang racket/gui (define address-field% (class text-field% (super-new) (inherit get-editor has-focus? focus) (define/override (on-focus on?) (eprintf "on-focus was ~a -> now ~a~n" (has-focus?) on?) (queue-callback (lambda () (eprintf "later: has focus? ~a~%" (has-focus?))))))) (define f (new frame% [label "hello"] [width 100] [height 100])) (define a (new address-field% [parent f] [label "test "])) (send f show #t)


javier123mendoza
2021-6-17 13:14:42

Hi,I have a question. Is it possible to define from a subcontext to the top-level context? For example (define (ctxt) (define x 1) x) (println (ctxt)) x ;<- this identifier does not exist. I know it ;But could I define from the ctxt in top-level context? ;For example using the syntax information to create a new id X:line:pos. (define-namespace-anchor nsa) (define ns (namespace-anchor->namespace nsa)) (define (ctxt1) (define x 1) (namespace-set-variable-value! 'x x #t ns) x) (ctxt1) x;; unbound identifier in phase 1 (provide x)


jjsimpso
2021-6-17 13:36:23

So is this a bug then? I can open a bug if it is.


jjsimpso
2021-6-17 13:39:12

I just want to make sure I’m not misinterpreting the documentation for has-focus?


greg
2021-6-17 16:23:11

If your goal is to provide it, that is, at compile time (phase 1), then you’ll need to define it at compile time. You could do that directly with (define x #t) or you could write a macro to write it for you — for example: (define-syntax (define-x stx) #'(define x #t)) (define-x) (provide foo) If instead your goal is to have some runtime (phase 0) mapping of symbols like x to values, then probably you want to use a hash-table.


greg
2021-6-17 16:23:52

There might be a way to (ab)use eval at runtime, but that’s usually not a great idea: https://blog.racket-lang.org/2011/10/on-eval-in-dynamic-languages-generally.html


greg
2021-6-17 16:26:18

Someone else may have a better explanation or idea for you, but since no one else had replied yet I thought I’d give it a shot.


javier123mendoza
2021-6-17 16:46:43

thank you for your time. I am trying to make a similar to a global hash table. Only instead of keys to access I want to be able to do it with binding identifiers. But the definition of those table values is done at compile time.


jjsimpso
2021-6-17 17:53:08

hazel
2021-6-17 17:57:20

is there a parameter for setting the thickness of the box when running plot? if not, what is that thickness? talking about the box drawn around axes (please excuse the nonsense labels this is just the best example I had saved)


capfredf
2021-6-17 19:32:49

@greg I have seen some visual glitches of Racket-mode with Emacs 28, which I have never run into with Emacs 27. Given that emacs 28 is not released, I am not sure if I should post an issue


greg
2021-6-17 20:40:15

Please do go ahead and post an issue! (if you don’t mind)

[My “daily driver” is still Emacs 26.2 from Ubuntu 18.04. Planning to upgrade in near future at least-disruptive chance.]


greg
2021-6-17 20:46:01

Also I’ll refresh/rebuild emacs-snapshot and try to spend more time using racket-mode with 28.0.50, to spot problems myself, even if I’m not daily dog-fooding it.


sschwarzer
2021-6-17 21:42:03

Wow: https://felleisen.org/matthias/Thoughts/Apology.html (was linked in the HN discussion)


samdphillips
2021-6-17 22:25:13

Is there a way to say all of the module files under some path are in #lang somelang if they don’t have the #lang line? Maybe something in an info file?


alexharsanyi
2021-6-17 22:35:08

The lines are the axes of the plot and whether they are drawn or not is controlled by plot-{x,y}{-far}?-axis? parameters. The width of the line is controlled by plot-line-width and its color by plot-foreground. Looks like plot-line-width is not documented….

(parameterize ([plot-line-width 3] [plot-foreground "blue"] [plot-x-axis? #f]) (plot (function sin -1 1)))


greg
2021-6-17 23:32:34

@capfredf One thing I see is with racket-xp-mode enabled and using the default pseudo-tooltip show method: When a pseudo tooltip does not cover the end of the line, there is a space after the tooltip.


capfredf
2021-6-17 23:38:08

@greg the problem I see is indeed about tooltips. A tooltip sometimes push the a portion of the line it overlays. I will post an issue later today and I will attach screenshots


greg
2021-6-17 23:40:21

Thanks — that sounds like a problem I’m seeing. It looks like the Emacs function window-text-pixel-size is behaving differently in 28.0.50. But if you do have time to log it, that would be great — you might be seeing something else, too. Thanks!!


samth
2021-6-18 01:17:22

No, there isn’t a mechanism like that.


samth
2021-6-18 01:24:51

It’s somewhat intentional, in that a goal of Racket is the semantics of the program are controlled by the program itself — that’s the goal of #lang in the first place.


samdphillips
2021-6-18 01:27:22

I understand. I was poking around at porting a r7rs code base and trying to see how to work around having to tag each source file with a lang line. For this specific use case it seems to work better to create a rkt file for each scheme file and just include it.


samdphillips
2021-6-18 01:27:51

Which is a fairly straightforward shell script :stuck_out_tongue:


shu--hung
2021-6-18 02:14:10

Does every program in r7rs runs in top-level mode? Like in a REPL?


shu--hung
2021-6-18 02:14:58

If so, there’s a flag to treat files as sequences of top-level expressions instead of modules


samdphillips
2021-6-18 04:09:07

Not as I understand the semantics and how Alexis has implemented the lang. I’m trying to solve the problem of not having to alter the original source code too much just for Racket specific syntax (ie #lang lines) because then (in theory) I could send the upstream library some minimal diffs to the code.