Re: [racket-users] [racket users] scribble using @ as text?

2020-09-24 Thread Sorawee Porncharoenwase
I think you meant `@"@"`? `@["@"]` is an application. On Thu, Sep 24, 2020 at 2:31 PM Jay McCarthy wrote: > @["@"] > > -- > Jay McCarthy > Associate Professor @ CS @ UMass Lowell > http://jeapostrophe.github.io > Vincit qui se vincit. > > > On Thu, Sep 24, 2020 at 5:26 PM Kevin Forchione

Re: [racket-users] [racket users] scribble using @ as text?

2020-09-24 Thread Sorawee Porncharoenwase
See https://docs.racket-lang.org/scribble/reader.html#%28part._.The_.Scribble_.Syntax_at_a_.Glance%29 On Thu, Sep 24, 2020 at 2:26 PM Kevin Forchione wrote: > Hi guys, > I’ve been racking my brains and going through scribble manuals trying to > figure out how to do something as simple as

Re: [racket-users] Why are these @defthing blocks typeset incorrectly?

2020-09-23 Thread Sorawee Porncharoenwase
Caution: I haven’t tried your code yet. I think Scribble uses source location equipped with syntax objects to figure out spacing. Since you generate stuff on the fly, there’s no source location, so the rendered text is screwed up. An idea I have (which might not work) is to use write /

Re: [racket-users] package manager woes on Windows 10?

2020-09-14 Thread Sorawee Porncharoenwase
uld probably add a 'single-no-return style and then grep > the codebase for places that use 'single and change them (as appropriate). > > Robby > > > On Sun, Sep 13, 2020 at 3:15 PM Sorawee Porncharoenwase < > sorawee.pw...@gmail.com> wrote: > >> I meant, wouldn’t

Re: [racket-users] package manager woes on Windows 10?

2020-09-13 Thread Sorawee Porncharoenwase
I meant, wouldn’t it be better to fix text-field% itself, instead of only some instances of it? Sorry if that was confusing. On Sun, Sep 13, 2020 at 1:12 PM Sorawee Porncharoenwase < sorawee.pw...@gmail.com> wrote: > Should the fix apply to all 'single styled text-field% > <http

Re: [racket-users] package manager woes on Windows 10?

2020-09-13 Thread Sorawee Porncharoenwase
Should the fix apply to all 'single styled text-field% too? On Sun, Sep 13, 2020 at 7:50 AM Robby Findler wrote: > Yea, I agree. I'd made that change locally but hadn't pushed because I > couldn't make the bad behavior happen reliably. Perhaps

Re: [racket-users] -i as an identifier

2020-09-10 Thread Sorawee Porncharoenwase
I think you read the doc correctly, but there are programs that use +i and -i, so it's unclear if fixing the reader is desirable. Perhaps the documentation should be adjusted instead. Here’s an example of how people use +i and -i:

Re: [racket-users] Making expanded bindings visible in top-level

2020-09-06 Thread Sorawee Porncharoenwase
I think it’s only enough to fabricate the #%info-* identifiers. For example, in the file you linked above, you can add: [#%info-domain (datum->syntax stx '#%info-domain)] to with-syntax, and provided that you provide #%top-interaction, you should be able to use #%info-domain in the REPL. On

Re: [racket-users] Re: provide-if-not-defined

2020-09-03 Thread Sorawee Porncharoenwase
I want to propose another interface: (my-provide #:default + - * #:override [my-+ +]) which expands to: (provide - *) (provide (rename-out [my-+ +])) and checks that + must be in the #:default section (because we are overriding it, it’d better already exist). More generally:

Re: [racket-users] provide-if-not-defined

2020-09-02 Thread Sorawee Porncharoenwase
IIUC, that’s not what Shriram wants. He wants a kind of interface / contract for a module (that it must export certain identifiers). The solution that you posted makes the module satisfy the interface by construction, but it creates another problem which is that he might accidentally export a

Re: [racket-users] Is this running in DrRacket or as a script?

2020-09-02 Thread Sorawee Porncharoenwase
Using Laurent’s suggestion, you can also create a global variable / parameter that will be set by the drracket submodule. That way, you can create running-in-drracket? and use it inside functions. On Wed, Sep 2, 2020 at 12:54 AM Laurent wrote: > You can use a `drracket` submodule: > > (module+

Re: [racket-users] printing errors

2020-08-29 Thread Sorawee Porncharoenwase
Alternatively, I think you can simply supply a non-exception value to the handler. This will suppress the red cross icon too, though. (define (print-exn exn) ((error-display-handler) (if (exn? exn) (exn-message exn) (format "~a" exn)) #f)) On Sat, Aug 29, 2020 at 8:17 AM

Re: [racket-users] graphical debugging

2020-08-29 Thread Sorawee Porncharoenwase
I meant the REPL in DrRacket (interaction window). On Sat, Aug 29, 2020 at 5:21 AM Catonano wrote: > Il giorno sab 29 ago 2020 alle ore 12:11 Sorawee Porncharoenwase < > sorawee.pw...@gmail.com> ha scritto: > >> It (kinda) works for me. You should make sure that

Re: [racket-users] graphical debugging

2020-08-29 Thread Sorawee Porncharoenwase
It (kinda) works for me. You should make sure that debugging is enabled in the language setting (it should display something like “Language: racket, with debugging [custom]” in the REPL). Then, click “Debug” and then click “Step” for a couple of times (seven to be precise). The little green

Re: [racket-users] printing errors

2020-08-27 Thread Sorawee Porncharoenwase
For stacktrace, use error-print-context-length to suppress it: (define (print-exn exn) (parameterize ([error-print-context-length 0]) ((error-display-handler) (if (exn? exn) (exn-message exn) (format "~a" exn)) exn))) I don’t see any extra newline though. On

[racket-users] Re: [racket-dev] Does the Guide need to mention syntax parse & does the Style guide need to provide guidance?

2020-08-23 Thread Sorawee Porncharoenwase
The guide seems to be for the Racket code base (https://github.com/racket) rather than general Racket code, so I don't think it should say "prefer syntax-parse over syntax-case". I do think there should be a style guide for general Racket code (which could very well be based on the style guide

Re: [racket-users] Deserializing snips from untrusted input

2020-08-20 Thread Sorawee Porncharoenwase
I don't know much about this specific case, but see Robby's comment about how "DrRacket can run user (untrusted) code in certain situations" at https://github.com/racket/gui/issues/157. A concrete problem I found is that you can have a snip running `struct->vector` and it will successfully extract

Re: [racket-users] Re: Application Templates!

2020-08-20 Thread Sorawee Porncharoenwase
Is this intended to be something like https://docs.racket-lang.org/scaffold/ ? On Thu, Aug 20, 2020 at 10:12 AM Stephen De Gabrielle < spdegabrie...@gmail.com> wrote: > Alex is right, most developers don't need this. > > The point of templates is

Re: [racket-users] Re: Strange performance behavior

2020-08-07 Thread Sorawee Porncharoenwase
I even saw people doing `collect-garbage` three times, just to be safe I guess. And yet theoretically it's not guaranteed that things will be claimed back properly. Honestly, there should be a function that does this `collect-garbage` until fixpoint or something, so that we don't need to perform

Re: [racket-users] Racket v7.8

2020-08-04 Thread Sorawee Porncharoenwase
uted to this release: > > > > > > Alex Harsányi, Alex Knauth, Alexander Shopov, Alexis King, Andrew > Kent, > > > Andrew Mauer-Oats, Atharva Raykar, Ben Greenman, Benjamin Yeung, Bert > De > > > Ketelaere, Bogdan Popa, David Christiansen, David Florn

Re: [racket-users] pictures in code?

2020-08-02 Thread Sorawee Porncharoenwase
For DrRacket, it's possible via "Insert > Insert Image". It's been used in HtDP. See https://htdp.org/2020-8-1/Book/part_prologue.html On Sun, Aug 2, 2020 at 7:07 PM Hendrik Boom wrote: > Is there any way to include pictures in Racket code? > Perhaps as constants or as prts of identifiers? >

[racket-users] Re: with-continuation-marks in errortrace

2020-07-26 Thread Sorawee Porncharoenwase
(By "integrating" with the new strategy, I meant having two keys: one for the new strategy and one for the old strategy. I can see that the first entry of the old strategy is useful, and it's missing in the new strategy). On Sun, Jul 26, 2020 at 8:21 PM Sorawee Porncharoenwase &l

[racket-users] with-continuation-marks in errortrace

2020-07-26 Thread Sorawee Porncharoenwase
Hi everyone, I have a question about the implementation of errortrace. Consider the classic factorial program, except that the base case is buggy: (define (fact m) (let loop ([n m]) (cond [(zero? n) (/ 1 0)] [else (* (loop (sub1 n)) n)]))) (fact 5) Running this program with

Re: [racket-users] catalog not working?

2020-07-23 Thread Sorawee Porncharoenwase
Though, considering that there are so many people who are misled that the catalog is down (my past self included), it might be better if that page displays some useful information rather than a 404. On Thu, Jul 23, 2020 at 8:12 PM Sorawee Porncharoenwase < sorawee.pw...@gmail.com>

Re: [racket-users] catalog not working?

2020-07-23 Thread Sorawee Porncharoenwase
The catalog is functional. That path is simply not served. See also: From: Matthew Flatt Date: Thu, Feb 27, 2020 at 3:00 PM Subject: Re: [racket-users] download catalog down? To: Tom Gillespie Cc: Racket Users That path isn't served, but something like

Re: [racket-users] Multiple stage compilation in a tower of languages

2020-07-23 Thread Sorawee Porncharoenwase
local-expand supports the stop-list argument, so I think you can put all core forms there. #lang racket (require syntax/parse/define) (define-syntax (A-core stx) (syntax-parse stx #:literals (b-core) [(A-core (b-core x)) #'(printf "A-core got value ~a.~n" x)])) (define-syntax (b-core

Re: [racket-users] combining require, build-path, and namespaces

2020-07-21 Thread Sorawee Porncharoenwase
This is weird. I usually parameterize current-namespace when using namespace-* functions, and in this particular case it works fine. On Tue, Jul 21, 2020 at 11:05 AM Shriram Krishnamurthi wrote: > Thank you! Would you know why I might get this error: > > ; require: unknown module > > ; module

Re: [racket-users] reading s-expressions from a file

2020-07-17 Thread Sorawee Porncharoenwase
(with-input-from-file "abc" (thunk (sequence->list (in-port Note that you need to “read” in the dynamic extent of with-input-from-file. Outside it, the port is closed. On Fri, Jul 17, 2020 at 5:19 PM Hendrik Boom wrote: > Yes, I know the functino for reading s-expressions seems to be

Re: [racket-users] Are Regular Expression classes Unicode aware?

2020-07-09 Thread Sorawee Porncharoenwase
? But yes, the problem is definitely due to readline. Sam suggested me to try racket -q which suppresses readline, and the result is that there’s no issue. On Thu, Jul 9, 2020 at 11:43 AM Philip McGrath wrote: > On Thu, Jul 9, 2020 at 10:32 AM Sorawee Porncharoenwase < > sorawee.pw...@

Re: [racket-users] Are Regular Expression classes Unicode aware?

2020-07-09 Thread Sorawee Porncharoenwase
Racket REPL doesn’t handle unicode well. If you try (regexp-match? #px"^[a-zA-Z]+$" "héllo") in DrRacket, or write it as a program in a file and run it, you will find that it does evaluate to #f. On Thu, Jul 9, 2020 at 7:19 AM Peter W A Wood wrote: > I was experimenting with regular expressions

Re: [racket-users] Is there a way to open (and just view) a Racket file (e. g. .rkt or .scrbl extensions) from Google Drive?

2020-07-07 Thread Sorawee Porncharoenwase
A quick Google returns this site: https://superuser.com/questions/659666/how-do-i-get-google-drive-to-open-text-files-with-arbitrary-extensions-as-text-f So it looks like there's no way if you are not willing to rename files or use a third-party text editor in Google Drive. On Tue, Jul 7, 2020

Re: [racket-users] Wrong result from a define-syntax with pattern maching on a hash table

2020-07-06 Thread Sorawee Porncharoenwase
#lang scribble/manual @(require (only-in racket ~a)) @(define persons (list (hash 'name 'name1 'e-mail 'email1 'nickname 'nickname1) (hash 'name 'name2

Re: [racket-users] Wrong result from a define-syntax with pattern maching on a hash table

2020-07-06 Thread Sorawee Porncharoenwase
t step to try > to achieve that (it's also the first time I try a non toy program in any > Lisp). > > Le lundi 6 juillet 2020 20:04:27 UTC+9, Sorawee Porncharoenwase a écrit : >> >> What's wrong with `match`? It seems to be what you want. Macro is not >> going to help you h

Re: [racket-users] Wrong result from a define-syntax with pattern maching on a hash table

2020-07-06 Thread Sorawee Porncharoenwase
What's wrong with `match`? It seems to be what you want. Macro is not going to help you here. On Mon, Jul 6, 2020 at 3:47 AM Oualmakran Yassine wrote: > Hello, > > I have some difficulties when trying to create a macro doing some pattern > matching on a hash-table and was hoping finding some

Re: [racket-users] Wills, plumbers, and checking if a port is closed

2020-06-30 Thread Sorawee Porncharoenwase
It doesn't look like will executor will do what you want, since it has to do with garbage collection rather than port closing. This could be overkill, but it's possible to construct a custom port ( https://docs.racket-lang.org/reference/customport.html). Is it possible to construct a new port

Re: [racket-users] Re: identifier used out of context

2020-06-07 Thread Sorawee Porncharoenwase
with your macro rather than block) > > On Sunday, June 7, 2020 at 4:27:24 PM UTC-6, Sorawee Porncharoenwase wrote: >> >> Perhaps I missed something, but the error in the first example is because >> there’s no expression at the end of let. If I use this code instead, it &g

Re: [racket-users] Re: identifier used out of context

2020-06-07 Thread Sorawee Porncharoenwase
an > `'origin` property on `5`) doesn't match. > > > > On Sunday, June 7, 2020 at 12:18:26 AM UTC-6, Sorawee Porncharoenwase > wrote: >> >> Thank you so much, Michael! This is very helpful. >> >> I can see that when this form is used within another interna

Re: [racket-users] Re: identifier used out of context

2020-06-07 Thread Sorawee Porncharoenwase
bound by later definitions are available. > > On Saturday, June 6, 2020 at 4:15:00 AM UTC-6, Sorawee Porncharoenwase > wrote: >> >> Ah, apparently I need syntax-local-identifier-as-binding. Here’s a >> revised code that passes the tests. >> >> (begin-for-sy

[racket-users] Re: identifier used out of context

2020-06-06 Thread Sorawee Porncharoenwase
, it seems to work equally well. On Fri, Jun 5, 2020 at 6:30 PM Sorawee Porncharoenwase < sorawee.pw...@gmail.com> wrote: > Hi Racketeers, > > I’m creating a macro that collects values in the internal-definition > context. E.g., > > ($list > 1 > (define x 2) >

[racket-users] identifier used out of context

2020-06-05 Thread Sorawee Porncharoenwase
Hi Racketeers, I’m creating a macro that collects values in the internal-definition context. E.g., ($list 1 (define x 2) x) should evaluate to '(1 2). Here’s my implementation, and it kinda works: #lang racket (begin-for-syntax (define ((do-it gs ctx) e) (let loop ([e e])

Re: [racket-users] Re: Practical HTTP requests?

2020-05-17 Thread Sorawee Porncharoenwase
I did a web scraping in Racket a couple of months ago, and I agree that it is painful. On the bright side, Bogdan seems to start working on a practical requests-like library due to this thread, so we should have a good practical HTTP request library

Re: [racket-users] Make your computer talk in Racket on Windows in 5 lines

2020-05-16 Thread Sorawee Porncharoenwase
On Mac, there’s a say command, so this would do it. (system "say \"hello world\"") When I had a Linux machine, I recalled using a command named espeak, which is similar to say on Mac. On Sat, May 16, 2020 at 11:15 AM Sam Phillips wrote: > Stephen De Gabrielle and I are wondering if any Mac or

Re: [racket-users] at sign in scribble

2020-05-15 Thread Sorawee Porncharoenwase
See https://docs.racket-lang.org/scribble/reader.html?q=escape#%28part._.The_.Scribble_.Syntax_at_a_.Glance%29 Either of this works: - @bold{a@"@"b} - @bold|{a@b}| On Fri, May 15, 2020 at 5:04 AM Hendrik Boom wrote: > I hae not been able to figure out from the scribble documentation how to >

Re: [racket-users] Re: Racket Program doesn't save

2020-05-11 Thread Sorawee Porncharoenwase
Does tst.rkt get created? I use racket-7.7-x86_64-macosx and run macOS Catalina too, but could not reproduce the problem. On Mon, May 11, 2020 at 2:56 PM Sai Ganesh Buchireddy wrote: > After I save the file and try to close Dr. Racket, I get the msg saying > the file is not saved as shown in

Re: [racket-users] for/set

2020-05-08 Thread Sorawee Porncharoenwase
There’s a search bar in the top left of every doc page. Typing for/set and enter will show you this search result page . Here, the first result

Re: [racket-users] for/stream and values

2020-05-03 Thread Sorawee Porncharoenwase
> > Thank you for the package! So, do I understand correcty that it is > impossible to produce multi-valued streams with for/stream? If so, maybe > it's worth adding a note about it to the documentation of for/stream? > That is correct. Feel free to submit a PR to improve the documentation. You

Re: [racket-users] for/stream and values

2020-05-02 Thread Sorawee Porncharoenwase
I just created a package that helps creating a stream of multiple values a couple of weeks ago. You might find it useful: https://docs.racket-lang.org/stream-values/ On Sat, May 2, 2020 at 3:38 PM Yury Bulka wrote: > (sorry for the typos - obviously, it should be racket/stream) > > -- > Yury

Re: [racket-users] Questions about working on DrRacket and gui

2020-05-01 Thread Sorawee Porncharoenwase
Sam just suggested me in the other email thread that a much easier way to do things is to download and install Minimal Racket, then install DrRacket from source. On Fri, May 1, 2020 at 7:59 AM Dexter Lagan wrote: > Hi, > > I apologize in advance if my questions are naïve or have been asked >

Re: [racket-users] Reducing parentheses without language damage.

2020-04-30 Thread Sorawee Porncharoenwase
> > I hate being at the mercy of whatever editor I'm stuck using. I agree with this in principle, but in practice, it's really a matter of what mainstream editors support. Editors in the past don't universally support automatic indentation, and I could imagine a criticism like "Indentation

Re: [racket-users] on reducing barriers in the Racket community

2020-04-30 Thread Sorawee Porncharoenwase
race doesn't enabled. > > To be clarify, what you mentioned is "Preserve errortrace" option, what > about "Debugging" option, is it a must enabled option in a non-debugging > run? > > <截圖 2020-04-25 下午9.22.20.png> > > > Sorawee Porncharoenwase 於

Re: [racket-users] Rhombus project plan

2020-04-29 Thread Sorawee Porncharoenwase
(Not directly related to Rhombus) Speaking of “how to contribute”, I find that it is not friendly at all to setup stuff in order to contribute to Racket core and main distribution. According to https://blog.racket-lang.org/2017/09/tutorial-contributing-to-racket.html, if I want to make a change

Re: [racket-users] on reducing barriers in the Racket community

2020-04-25 Thread Sorawee Porncharoenwase
> > I like the idea of adding a "with debugging" to the banner when a program > is run in DrRacket, but I´m not sure it is possible. > It current exists already! The screenshot I attached above is from the actual DrRacket when debugging is enabled. > (It would be even better if the user can

Re: [racket-users] on reducing barriers in the Racket community

2020-04-25 Thread Sorawee Porncharoenwase
It could go either way, no? I've also heard a lot of people complaining that debugging Racket programs is difficult because the stack trace is not useful, and this is because they use the command-line version which doesn't have errortrace enabled (by default). Perhaps what you really are

[racket-users] DrRacket's dark mode: anyone familiar with Windows internals?

2020-04-25 Thread Sorawee Porncharoenwase
Hi everyone, DrRacket's dark mode currently doesn't work on Windows. If you know Windows internals and would like to help, you can participate at https://github.com/racket/drracket/issues/235. -- Forwarded message - From: Robby Findler Date: Fri, Apr 24, 2020 at 7:32 PM Subject:

Re: [racket-users] Gradual Typed Racket?

2020-04-17 Thread Sorawee Porncharoenwase
> > My understanding is that contract-out only provides protection against > inappropriate calls from clients *outside* the module, whereas > define/contract enforces the contract against everyone, including things > inside the module. Do I have that right? > I think that's correct. Note though

Re: [racket-users] rename-in issue

2020-04-09 Thread Sorawee Porncharoenwase
There are two colliding names. make and interface-version. As shown in the error message, you fixed one but not the other. (require net/url web-server/dispatchers/filesystem-map web-server/dispatchers/dispatch-files (rename-in web-server/dispatchers/dispatch-sequencer

Re: [racket-users] Suggestions for "The Racket Guide"

2020-04-08 Thread Sorawee Porncharoenwase
Thoughts: - I take a look at the compiled HTML document. It doesn't seem suffice to only change JavaScript because the information about "what is the input" is pretty much lost at the HTML level. - IIUC, Scribble targets older version of HTML (HTML4?), so it doesn't really care about the

Re: [racket-users] Best way to handle different versions of Racket?

2020-03-30 Thread Sorawee Porncharoenwase
uld be OK, right? > Re: reason to use it - performance. I'm applying the string-append > operation in a pairwise way over input sequences, and re-converting to > immutable at each step appears to have a measurable cost. > > > On Mon, Mar 30, 2020 at 12:11 PM Sorawee Porncharoenwase

Re: [racket-users] Best way to handle different versions of Racket?

2020-03-30 Thread Sorawee Porncharoenwase
Mar 30, 2020 at 12:00 PM Sorawee Porncharoenwase < sorawee.pw...@gmail.com> wrote: > Your code would not work because prior 7.5.0.14, there’s no > string-append-immutable, so the use of string-append-immutable in the > else branch will result in an unbound id error. >

Re: [racket-users] Best way to handle different versions of Racket?

2020-03-30 Thread Sorawee Porncharoenwase
Your code would not work because prior 7.5.0.14, there’s no string-append-immutable, so the use of string-append-immutable in the else branch will result in an unbound id error. Instead, use https://docs.racket-lang.org/version-case/index.html which will run the “if” at compile-time, making the

Re: [racket-users] Code Jam

2020-03-30 Thread Sorawee Porncharoenwase
It’s a programming competition by Google. https://codingcompetitions.withgoogle.com/codejam Code Jam used to allow participants to use any languages, but they changed that a couple of years ago. To quote its website: With the new platform, we have aimed to support the most popular programming

Re: [racket-users] Understanding P. Ragde's Proust

2020-03-15 Thread Sorawee Porncharoenwase
You need to add a case in parse-expr to deal with annotations, which is in the form ( : ). E.g., [`(,e : ,t) (TA (parse-expr e) (parse-type t))] On Sun, Mar 15, 2020 at 7:21 AM Adrian Manea wrote: > Hi Matt, > > Thank you very much for the details! What you're saying makes sense and is > in

Re: [racket-users] why is glCreateVertexArrays absent?

2020-03-08 Thread Sorawee Porncharoenwase
Have you tried this? https://github.com/dbenoit17/dynamic-ffi On Sun, Mar 8, 2020 at 5:52 AM Hendrik Boom wrote: > On Sat, Mar 07, 2020 at 07:32:01AM -0800, Sorawee Porncharoenwase wrote: > > I know nothing about OpenGL, but the autogeneration > > <https://github.com/stepha

Re: [racket-users] why is glCreateVertexArrays absent?

2020-03-07 Thread Sorawee Porncharoenwase
I know nothing about OpenGL, but the autogeneration seems to read the information from this directory , which was last updated 7 years ago (2013). OpenGL

Re: [racket-users] xexpr cond failing

2020-03-01 Thread Sorawee Porncharoenwase
Actually you might want to use (list (let () body ...)) rather than (list (begin body ...)) so that you can use define inside when/splice, just like how you can do that in when. On Sun, Mar 1, 2020 at 3:26 AM Sorawee Porncharoenwase < sorawee.pw...@gmail.com> wrote: > Well, you can a

Re: [racket-users] xexpr cond failing

2020-03-01 Thread Sorawee Porncharoenwase
ng unnecessary > code to make the xexpr valid which can be really annoying if having nested > cases or other more complex situations. Thanks again for your fast reply! > > On Sunday, March 1, 2020 at 7:43:20 PM UTC+11, Sorawee Porncharoenwase > wrote: >> >> One possible way is to

Re: [racket-users] xexpr cond failing

2020-03-01 Thread Sorawee Porncharoenwase
One possible way is to have the first case returns a list of one element, and the else case returns an empty list. You then splice this list into body via ,@. `(body (form ((action "") (method "post")) (label ((for "username")) "Username:") (input ((type "text") (name

Re: [racket-users] Starting syntax highlighter project

2020-02-19 Thread Sorawee Porncharoenwase
On Wed, Feb 19, 2020 at 11:55 PM Sage Gerard wrote: > I'm very much in favor of interoperability and am happy to work in that > direction. Does this imply that we need a #lang for each highlighting > target? With my approach, yes, but note that technically, the #lang doesn't need to be

Re: [racket-users] Starting syntax highlighter project

2020-02-19 Thread Sorawee Porncharoenwase
In my opinion, it would be very cool if the project is based on DrRacket’s color-lexer ecosystem. So instead of writing an ad-hoc lexer for, say, Python, we instead help improving the existing #lang python‘s color-lexer. Pro: - The result will look just like what DrRacket displays. -

Re: [racket-users] Re: How to convert String to Integer

2020-02-11 Thread Sorawee Porncharoenwase
You can convert a string to a list of characters by using string->list. The code snippet that you presented in your very first post also uses this function. > (string->list "abc") - : (Listof Char) '(#\a #\b #\c) What I want to ask you though is what is wrong with the code that Phillip

Re: [racket-users] how to reinstall a broken package?

2020-01-23 Thread Sorawee Porncharoenwase
I usually do raco setup --pkgs On Thu, Jan 23, 2020 at 8:34 AM Hendrik Boom wrote: > My installation of OpenGL Mathematics (GLM) for Racket is defective > in that the installed manual has tha complete table of contents but does > not > have any content past section 2.1.1. > This may be

Re: [racket-users] DrRacket Dark Mode in Windows

2020-01-17 Thread Sorawee Porncharoenwase
s that >> correct?" >> >> You are correct. Currently I have the editor with a dark theme >> (Spacemacs), but the DrRacket UI itself is light, even though I set it to >> "Dark" in Windows settings. >> >> Thank you for seeking clarification! >&

Re: [racket-users] How do I provide a name as both a match expander and contracted function?

2019-12-30 Thread Sorawee Porncharoenwase
IIUC, this is what Alex Knauth did in https://github.com/mbutterick/txexpr/pull/8. On Mon, Dec 30, 2019 at 7:07 PM Jack Firth wrote: > If I'm making my own data types, one common thing I want to do is make > smart constructors that double as match expanders. I could use >

Re: [racket-users] DrRacket 7.5 colors a bit dark and low contrast on Mac

2019-12-06 Thread Sorawee Porncharoenwase
Confirm that I have this problem as well, even when I reset all preference files. On Fri, Dec 6, 2019 at 11:17 AM Daniel Prager wrote: > Hi Robby > > > What happens if you open the preferences dialog and turn white-on-Black > on and back off again? > > No change. > > I still have 7.2 on my

Re: [racket-users] Limiting consecutive identical elements with match

2019-12-04 Thread Sorawee Porncharoenwase
This is super cool indeed. Now I feel stupid. On Wed, Dec 4, 2019 at 2:56 PM Matthew Butterick wrote: > > On Dec 4, 2019, at 2:39 PM, 'Joel Dueck' via Racket Users < > racket-users@googlegroups.com> wrote: > > So it seems easy to match "*at least *N identical elements". > But is there a method

Re: [racket-users] xml library clarification - "" symbol parsing

2019-11-22 Thread Sorawee Porncharoenwase
I’ll probably do this if I were you: #lang racket (require xml) (struct data (b1 b2) #:transparent) ;; extract :: XExpr -> (Listof data?) (define (extract xexpr) (match-define `(ROOT () ,xs ...) xexpr) (for/list ([e xs] #:when (list? e)) (match-define `(A () ,b1 ,b2) e) (data b1

Re: [racket-users] Efficient idiom for converting key-set of a hash-map into a hash-set

2019-10-25 Thread Sorawee Porncharoenwase
It also might be worth trying `(for/set ([(k v) (in-hash h)]) k)`. On Fri, Oct 25, 2019 at 1:19 PM David Storrs wrote: > On Fri, Oct 25, 2019 at 10:28 AM Thomas Dickerson > wrote: > > > > For reasons that are unclear to me, hash-keys and dict-keys both return > a list? instead of a set?

Re: [racket-users] Simple macro issues

2019-09-08 Thread Sorawee Porncharoenwase
This works for me: #lang racket (define (hex:char x) (if (number? x) x (string->number (symbol->string x) 16))) (define-syntax-rule (hex num ...) (bytes (hex:char (quote num)) ...)) (hex a b c 1 2 3) ; #"\n\v\f\1\2\3" It’s almost always a mistake to use a function that

Re: [racket-users] Listing All Programs

2019-09-05 Thread Sorawee Porncharoenwase
Oh, this is easy. The grammar of Racket is #lang * which, as I showed above, is expressible as regular expression. Regular languages are easily decidable :) On Thu, Sep 5, 2019 at 9:07 PM Laurent wrote: > Although it's not about checking, but generating, which *may* be easier. > (Though if

Re: [racket-users] Re: The case, and a proposal, for elegant syntax in #lang racket2

2019-08-21 Thread Sorawee Porncharoenwase
Pyret was a pain. Error messages were not clear and the whole change > confused students. > Can you elaborate more on this? My personal experience with Pyret is that it has an exceptionally good error message, except when an internal error occurs (which should not happen). Two language features

Re: [racket-users] Splicing the result of one macro into another

2019-08-21 Thread Sorawee Porncharoenwase
> > I appreciate all of the Racket documentation, but I think there is a need >> for a much better presentation of the material in a graduated way. >> > I think what you are saying is, there should be more Racket Guide content, and I think everyone agrees on that... > you seem to have an

Re: [racket-users] Splicing the result of one macro into another

2019-08-20 Thread Sorawee Porncharoenwase
1. You will need a cooperation of phone-numbers macro. There are two ways I am aware of 1.1 You could hard code in phone-numbers to deal with add-prefix directly. 1.2 A more general approach is to use local-expand in phone-numbers to partially expand macros in the body of

Re: [racket-users] Re: Macro containing a list of elements that each have optional keyword options

2019-08-19 Thread Sorawee Porncharoenwase
You could use (splicing) syntax class to help with normalization: #lang racket (require syntax/parse/define (for-syntax syntax/parse racket/syntax)) (begin-for-syntax (define-splicing-syntax-class methods-cls #:attributes (methods) (pattern (~seq

Re: [racket-users] [racket users] module question

2019-08-06 Thread Sorawee Porncharoenwase
You need: (module B racket (require (submod ".." A)) (printf "X=~a~%" X)) On Tue, Aug 6, 2019 at 3:58 PM Kevin Forchione wrote: > Is there a way to define 2 modules within a file and reference them or is > a file limited to 1 module only (but may have multiple submodules)? > > Here’s a

Re: [racket-users] Re: Do custodians shutdown when Racket exits?

2019-08-06 Thread Sorawee Porncharoenwase
I have a similar question on will executor. It doesn't seem to get run on program exiting/breaking. Do I need a plumber that calls `collect-garbage`? On Tue, Aug 6, 2019 at 10:27 AM David Storrs wrote: > I should mention that the reason I'm looking into this is because I have > UDP sockets that

Re: [racket-users] Why custom-display of printable<%> interface is called twice?

2019-07-28 Thread Sorawee Porncharoenwase
I’m not sure why it’s like that, but I know what’s the problem and how to fix it. custom-display and custom-write provide the output port to you. You are supposed to write to the port. (define/public (custom-display out) (displayln "custom-display" out)) (define/public

Re: [racket-users] Contracts referring to earlier elements?

2019-07-18 Thread Sorawee Porncharoenwase
Hi Kevin, Take a look at Racket Guide’s Argument and Result Dependencies and/or Racket Reference’s ->i

Re: [racket-users] The case, and a proposal, for elegant syntax in #lang racket2

2019-07-18 Thread Sorawee Porncharoenwase
> > The other thing I'd like to see would be the option to return nothing. > Not #, '(), or #f. Nothing. It's useful e.g. when you want to > simultaneously transform and filter a list. > Would (values) satisfy your criteria? #lang racket (define (my-filter-map proc xs) (match xs ['()

Re: [racket-users] raise-argument-error missing list?

2019-07-08 Thread Sorawee Porncharoenwase
On Mon, Jul 8, 2019 at 12:56 PM Greg Hendershott rac...@greghendershott.com wrote: - The return value is `any` -- not even `any/c`, just `any`. Effectively > don't check the return value(s). > If I use define/contract, does any restore tail-recursion?

Re: [racket-users] Trying to get my head around typed racket and higher order functions

2019-06-30 Thread Sorawee Porncharoenwase
inst is the way to go. How did you use it? This seems to work fine for me. #lang typed/racket (: create-points : (Listof Flonum) (Listof Flonum) -> (Listof (Vectorof Flonum))) (define (create-points xs ys) (map (inst vector Flonum) xs ys)) On Sun, Jun 30, 2019 at 1:03 AM greadey wrote: >

Re: [racket-users] Pattern matching as computation

2019-06-27 Thread Sorawee Porncharoenwase
If you want only one match, it seems what you really want is ~seq-like form from syntax/parse. E.g., #lang racket (require syntax/parse) (define ->value syntax->datum) (define (apply-lift op args) (datum->syntax #f (apply op (->value args (syntax-parse (vector 1 2 3 4) [#(a {~and

Re: [racket-users] Relative Pathname problem

2019-06-23 Thread Sorawee Porncharoenwase
This is almost certainly due to Geiser and not Racket. IIRC, there are C-c C-a and C-c C-b. One of them works with Racket and the other does not. If you only work with Racket, I would recommend racket-mode instead of Geiser. It's far more integrated to Racket. On Sun,

Re: [racket-users] symbols question

2019-06-20 Thread Sorawee Porncharoenwase
Is #%top what you are looking for? #lang racket (require syntax/parse/define) (define-simple-macro (#%top . x) 'x) (define x 42) x ;=> 42 y ;=> 'y (string-length (symbol->string abcdef)) ;=> 6 Unbound identifiers are wrapped with #%top

Re: [racket-users] macro guard question (ellipsis)

2019-06-18 Thread Sorawee Porncharoenwase
Also note that with syntax/parse, it becomes much easier: (require (for-syntax syntax/parse)) (define-syntax (foo stx) (syntax-parse stx [(_ (key:id val:id ...) ...) #'(quote (list ((quote key) (quote val) ...) ...))])) On Tue, Jun 18, 2019 at 8:56 PM Sorawee Porncharoenwase

Re: [racket-users] macro guard question (ellipsis)

2019-06-18 Thread Sorawee Porncharoenwase
I’d write this. Not sure if there’s a better way. (define-syntax (foo stx) (syntax-case stx () [(_ (key val ...) ...) (andmap identifier? (syntax->list #'(key ... {~@ val ...} ...))) #'(quote (list ((quote key) (quote val) ...) ...))])) On Tue, Jun 18, 2019 at 8:11 PM Kevin

Re: [racket-users] Why struct type doesn't include field names?

2019-06-15 Thread Sorawee Porncharoenwase
First of all, . won’t work in standard Racket because . has a special meaning (see https://docs.racket-lang.org/reference/reader.html#%28part._parse-pair%29). But yes, this is directly related to the discussion above because with the field name information, you can write your own accessor. #lang

[racket-users] Why struct type doesn't include field names?

2019-06-13 Thread Sorawee Porncharoenwase
Several struct extensions need to construct accessors unhygienically even though the accessors can be extracted from struct types. The reason is that there’s not enough information to establish connection between field names and accessors. For instance, consider struct* from racket/match. #lang

Re: [racket-users] Macro guards question

2019-05-29 Thread Sorawee Porncharoenwase
The issue is that #'arg will always be a syntax object. An identifier is a kind of syntax object, so it makes sense to test (identifier? #’arg). However, (symbol? #’arg) and (string? #’arg) will always fail. Suppose then that you invoke the macro with "1" as the operand, it would fail every case

Re: [racket-users] Trouble writing unhygienic macro

2019-05-27 Thread Sorawee Porncharoenwase
On Mon, May 27, 2019 at 7:54 PM Greg Hendershott wrote: > p.s. That (datum->syntax _ (string->symbol (syntax->datum _))) triplet > has an equivalent handy shortcut -- `format-id`: > > (format-id #'magic-name "~a" #'magic-name) This doesn't work in the string literal case because an argument

Re: [racket-users] redundancy in GUI callback functions

2019-05-25 Thread Sorawee Porncharoenwase
Just abstract the common part out? E.g., (define (update-text-field read-field write-field converter) (define text (send read-field get-value)) (cond [(string=? text "") (send read-field set-field-background (make-object color% 255 255 255 1)) (send write-field set-value "")]

  1   2   >