Re: [racket-users] Writing a "command-line front-end" for a language

2022-09-04 Thread Shu-Hung You
On Sun, Sep 4, 2022 at 4:21 AM Reuben Thomas wrote: > > On Sat, 3 Sept 2022 at 19:10, Shu-Hung You wrote: >> >> Running `racket foo.asm` will produce the desired output, so a shell >> script that directly passes the arguments to Racket could work. >> Otherwise, just

Fwd: [racket-users] Writing a "command-line front-end" for a language

2022-09-03 Thread Shu-Hung You
-- Forwarded message - From: Shu-Hung You Date: Sat, Sep 3, 2022 at 1:03 PM Subject: Re: [racket-users] Writing a "command-line front-end" for a language To: Reuben Thomas Running `racket foo.asm` will produce the desired output, so a shell script that directly

Re: [racket-users] Find the source location of the syntax error in DrRacket

2021-08-14 Thread Shu-Hung You
(make-rename-transformer (quote-syntax tmp)) >...)] ...) > () > body1 body ...))]) > (syntax/loc stx >(letrec-syntaxes+values ([(tmp ...) expr] ...) () > inner-body]))) > > and the butt

[racket-users] Find the source location of the syntax error in DrRacket

2021-08-13 Thread Shu-Hung You
Here are two syntax errors that behave differently in DrRacket: #lang racket (define-syntax (m-late stx) #'(let () (define x 0))) (define-syntax (m-early stx) #'(let-syntax () (define x 0))) ; (m-late) ; (m-early) DrRacket *correctly* highlights the source location of the errors in both cas

Re: [racket-users] Equivalent of exec

2021-08-03 Thread Shu-Hung You
On Tue, Aug 3, 2021 at 1:13 PM George Neuner wrote: > > > On 8/3/2021 1:03 PM, Norman Gray wrote: > > On 3 Aug 2021, at 17:38, George Neuner wrote: > > > >> Racket is multi-platform and tries to present a common API for > >> dealing with underlying operating systems. Windows is an important > >>

Re: [racket-users] Differences between execution in DrRacket and Command Line

2021-07-12 Thread Shu-Hung You
On Fri, Jul 2, 2021 at 10:25 AM Rhazes Spell wrote: > > Hello- > I have been using Racket for about 18 months for personal projects and > teaching. I have been doing all of my work in DrRacket but I wanted to > interact with a module that I wrote on the interactive command line this > morning.

Re: [racket-users] How to set type signature for recursive lazy list

2021-07-12 Thread Shu-Hung You
On Sun, Jul 11, 2021 at 8:15 PM Kiong-Gē Liāu wrote: > > Hi, in non-typed racket, I can define a generalized Fibonacci sequence > > X[n+k] = f(X[n], X[n+1], , X[n+k-1]) > > using the following code > > #lang racket > > (require racket/stream) > > (define (gfib f xs) > (define (gfib_t xs) >

Re: [racket-users] Inspiration for pict and 2htdp/image ?

2021-07-07 Thread Shu-Hung You
As of pict, from the slideshow paper I think the answer is yes and also many other prior works: https://users.cs.northwestern.edu/~robby/pubs/papers/icfp2004-ff.pdf > 6 Slideshow Design and Related Work > Slideshow’s pict language is by no means the first > language designed for generating pictur

Re: [racket-users] Re: machine and network outage at Northeastern

2021-07-02 Thread Shu-Hung You
The PLaneT website (https://planet.racket-lang.org/) is currently unreachable. The error message is ERR_CONNECTION_REFUSED. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an

Re: [racket-users] Why would writing to a pipe fail?

2021-06-16 Thread Shu-Hung You
Out of curiosity, I wrapped David's code in a loop and tried to write 509 bytes in each iteration. From the output, it looks like CS doesn't implement pipes using a fixed-size buffer. I'm also not sure how many different buffers there are. I think this has something to do with George's question. I

Re: [racket-users] Defining a function with the same name as a struct with a different constructor name

2021-06-03 Thread Shu-Hung You
In addition to the constructor, `foo` is also used for compile-time struct information. To avoid this, either supply #:name to designate a different identifier for compile-time struct type information, or declare #:omit-define-syntaxes to dismiss it. Shu-hung On Thu, Jun 3, 2021 at 4:04 PM Sage G

Re: [racket-users] student produces absolutely bonkers environment lookup code

2021-05-07 Thread Shu-Hung You
Not that I have any idea of what's going on, but interestingly, Typed Racket's second ->* example has (1)(3)(4). The use of list* may be possible if one follows the type (List* String Natural x) in the example. https://docs.racket-lang.org/ts-reference/type-ref.html?#%28form._%28%28lib._typed-rack

Re: [racket-users] put-image

2021-02-17 Thread Shu-Hung You
One option is using save-image from 2htdp/image to save the images as PNG files and open them using external programs. https://docs.racket-lang.org/teachpack/2htdpimage.html#%28def._%28%28lib._2htdp%2Fimage..rkt%29._save-image%29%29 If you can use a different language (say racket), another option

Re: [racket-users] Error while compiling Racket BC

2021-02-05 Thread Shu-Hung You
The snapshot build here may help: https://snapshot.racket-lang.org/ The HEAD version could add new internal primitives from time to time. Shu-Hung On Fri, Feb 5, 2021 at 5:52 PM 'Killian Zhuo (KDr2)' via Racket Users wrote: > > Thank you, does that mean I need a v8.0.0.5 to compile a v8.0.0.5?

Re: [racket-users] HtDP Tool Linklet Instantiation Error

2021-01-06 Thread Shu-Hung You
Some update: Hopefully this is the same issue as the one reported at https://github.com/racket/racket/issues/3604 and that the commit https://github.com/racket/drracket/commit/3a07fc0319097661d27ea05ba42634f2b5ae14dd fixes it. On Sun, Jun 17, 2018 at 10:15 PM Shu-Hung You wrote: > > No

Re: [racket-users] Is there a function to find and update all compiled directories?

2020-11-01 Thread Shu-Hung You
Using the command-line instruction `raco setup` will update all obsolete bytecodes. If you are looking for a programmable interface, `compiler/cm` is a good starting point. On Sun, Nov 1, 2020 at 5:43 PM infodeveloperdon wrote: > > I've never had problems with the .zo files being auto-created dur

Re: [racket-users] Clearer code in DrRacket?

2020-10-09 Thread Shu-Hung You
Here is an example that provides different colors for some particular forms such as define, require, lambda etc. However, these forms ('keywords') are recognized literally by the lexer instead of semantically as in Check Syntax. Therefore it will classify non-keywords as keywords from time to time.

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

2020-07-27 Thread Shu-Hung You
here will be no chance to identify which (/ y 0) caused the error. On Mon, Jul 27, 2020 at 1:13 PM Shu-Hung You wrote: > > By changing (fact 5) to (* 2 (fact 5)), the stack information becomes > > /: division by zero > errortrace...: >/Volumes/ramdisk/fact.rkt:6:17: (/ 1 0) &g

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

2020-07-26 Thread Shu-Hung You
By changing (fact 5) to (* 2 (fact 5)), the stack information becomes /: division by zero errortrace...: /Volumes/ramdisk/fact.rkt:6:17: (/ 1 0) /Volumes/ramdisk/fact.rkt:7:12: (* (loop (sub1 n)) n) /Volumes/ramdisk/fact.rkt:7:12: (* (loop (sub1 n)) n) /Volumes/ramdisk/fact.rkt:7:12:

Re: [racket-users] make-set!-transformer

2020-06-24 Thread Shu-Hung You
Here it is. https://github.com/racket/racket/blob/master/pkgs/racket-doc/scribblings/reference/stx-trans.scrbl#L31 I agree that it will be good to have a pointer or an example involving set!-values in the documentation of make-set!-transformer. The status quo is kind of indirect. The documentation

Re: [racket-users] syntax woe with typed Racket 'let'

2020-06-01 Thread Shu-Hung You
FWIW, because `.` is just cons, the program (define (F [X : T1] . [Y : T2]) 'e) is being read as: (define (F [X : T1] Y : T2) 'e) I guess that's the reason for having an extra '*' in the syntax. On Mon, Jun 1, 2020 at 10:16 PM Sam Tobin-Hochstadt wrote: > > The syntax looks like this: > >

Re: [racket-users] Annoying run-warnings in DrR 7.5: How to disable?

2020-01-24 Thread Shu-Hung You
On Fri, Jan 24, 2020 at 10:37 PM Jordan Johnson wrote: > > On 24 Jan 2020, at 14:00, Robby Findler wrote: > > In the preferences dialog, in the General tab, the last checkbox is > > the one you want. > > The one for saving files upon switching tabs? > That new options is added in the upcoming v7

Re: [racket-users] Re: Installing Drracket on linux penguin on Chromebook

2020-01-17 Thread Shu-Hung You
What's the result of `file /home/user/racket-tmp-install/bin/racket` and the result of `uname -a`? (In other words, what hardware are you using? Is it 32-bit or 64-bit, it is x86 or ARM? Which version of Racket did you download?) On Fri, Jan 17, 2020 at 12:21 PM William Dobias wrote: > >

Re: [racket-users] Installing Drracket on linux penguin on Chromebook

2020-01-16 Thread Shu-Hung You
Here's what I did: 1. Download the installer for x86_64 linux. 2. Move (or copy) the downloaded .sh file _into_ penguin through Files App. 3. Allow the installer to run by using `chmod +x FILE` (or `chmod 755 FILE`) * Chromrebook does not allow eXecutable permission for files outsi

[racket-users] Running DrRacket on Chromebook

2020-01-07 Thread Shu-Hung You
? Best, Shu-Hung -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. To view this discussion on the web vi

Re: [racket-users] file-position in Win32 not working beyond 1 GB

2019-12-20 Thread Shu-Hung You
On Fri, Dec 20, 2019 at 2:05 PM Shu-Hung You wrote: > > Could it be that the Racket layer importing rktio C code directly uses > get-ffi-obj and does not convert scheme_bignum_type to _int64? > Never mind this -- I got the FFI part wrong. > On Fri, Dec 20, 2019 at 2:01 PM Matth

Re: [racket-users] file-position in Win32 not working beyond 1 GB

2019-12-20 Thread Shu-Hung You
Could it be that the Racket layer importing rktio C code directly uses get-ffi-obj and does not convert scheme_bignum_type to _int64? @Dmitry: I guess Racket uses 1 bit for type tagging, leaving only 30+sign (or 62+sign) bits for the actual value. On Fri, Dec 20, 2019 at 2:01 PM Matthew Flatt wr

Re: [racket-users] reading code

2019-11-12 Thread Shu-Hung You
On Mon, Nov 11, 2019 at 10:30 AM Hendrik Boom wrote: > > On Fri, Oct 25, 2019 at 11:31:41AM +0200, Niklas Larsson wrote: > > Hi! > > > > If you right click on an identifier in drracket you get “jump to binding > > occurrence” and “jump to definition” (if it’s defined in another file). > > Don’t

Re: [racket-users] scribble cannot find module that racket finds

2019-11-03 Thread Shu-Hung You
On Sun, Nov 3, 2019 at 2:26 PM Hendrik Boom wrote: > > scribble does not find module "inclusion.rkt" even though racket does. > There must be a work-around, mustn't there? > > I can (require "inclusion.rkt") jusr fine from racket > > t3.rkt: > > #lang racket > (require "inclusion.rkt") > foo > > i

Re: [racket-users] Does match against list traverse the whole list?

2019-10-29 Thread Shu-Hung You
>From the expansion result, match does check whether the inspected value is a list using list?. But at least for the current version of Racket (and the C VM), list? is handled specially and ``effectively takes constant time due to internal caching.'' (quoted from: https://docs.racket-lang.org/refer

Re: [racket-users] Racket COM error opening Word document: expected argument of type <(opt (box any))>

2019-10-08 Thread Shu-Hung You
I don't know COM but here's an attempt to guess what happened based on the documentation. On Tue, Oct 8, 2019 at 11:51 AM Scott Gudeman wrote: > > I am working on converting a powershell script to Racket that takes a Word > XML document and saves it as PDF. > > In powershell, when I call Word's

Re: [racket-users] handin-server: writing a first checker

2019-08-23 Thread Shu-Hung You
I forgot to CC my reply to the list. The case here is that the user account data in `users.rktd` only contain one field but the default `extra-fields` configuration requires 3 extra fields. The error message probably comes from some (map cons ...) expression that resides in the server code. On

Re: [racket-users] Re: Using errortrace with repl-driven-development?

2019-07-24 Thread Shu-Hung You
errortrace with ,en should work as normal, as long as you ensure that there are no pre-compiled bytecode files (compiled/*.zo): $ ls myfile.rkt $ racket -l errortrace -i Welcome to Racket v7.2. > ,en "myfile.rkt" "myfile.rkt"> (f 123) ; g: 123 [,bt for context] "myfile.rkt"> ,bt ; g: 123 ; error

Re: [racket-users] file-position does not extend file as expected

2019-06-24 Thread Shu-Hung You
On Mon, Jun 24, 2019 at 4:09 PM David Storrs wrote: > > I actually did try writing something at the extended position, although I > removed it before posting the above. Even with a write, it still does not do > as expected. In fact, the results are even stranger: > > #lang racket > > (define (

Re: [racket-users] Re: catch and bind an unbound id in a macro

2019-04-20 Thread Shu-Hung You
identifier-binding returns #f for top-level bindings. I believe make-base-eval is evaluating expressions at top-level. On Sat, Apr 20, 2019 at 4:56 PM Ryan Kramer wrote: > > Below is a short example showing that identifier-binding doesn't seem to work > quite right with Scribble's make-base-eval

Re: [racket-users] Re: Intriguing performance difference between Windows and Linux on `(factorial 100000)`

2019-03-24 Thread Shu-Hung You
Interesting. This is the timing on Mac. Comparing to Alex's result, the numbers roughly match "< 7s" v.s. "> 13s" while fact-1 is close. $ racket Welcome to Racket v7.2.0.3. > (enter! "factorial.rkt") "factorial.rkt"> (equal? (fact 10) (fact-1 10)) #t "factorial.rkt"> (time (void (fact-1 1

Re: [racket-users] Cannot use case+else inside match+else

2019-02-27 Thread Shu-Hung You
And because it is nothing else but a usual binding, it's possible to prefix-in or rename-in as in (require (prefix-in r: racket/base)) (case 5 [r:else 'ok]) On Wed, Feb 27, 2019 at 7:32 AM Laurent wrote: > > Good point. I wasn't sure that would work---it does. > > On Wed, Feb 27, 2019 at 1:28 PM

Re: [racket-users] Cannot use case+else inside match+else

2019-02-25 Thread Shu-Hung You
rticular binding for 'else', but you > shadowed it with 'match', which does not treat 'else' differently than any > other identifier. > > Sam > > On Mon, Feb 25, 2019, 7:33 PM Shu-Hung You > wrote: >> >> When using a case expression

[racket-users] Cannot use case+else inside match+else

2019-02-25 Thread Shu-Hung You
When using a case expression with an else clause in inside a match expression, the expander complains about case having a bad syntax. However, the use of case expressions outside of match are fine. Is there anyway to get around this? Currently, I just replace it with another match. #lang racket/b

Re: [racket-users] struct-info

2019-02-12 Thread Shu-Hung You
On Tue, Feb 12, 2019 at 3:55 PM David Storrs wrote: > > On Tue, Feb 12, 2019 at 4:46 PM wrote: > >> > >> Thank you for the explanation. Can I ask why the heck it works this > >> way? This seems to be explicitly designed for maximal surprise and > >> minimal usefulness. > > > > > > It works that

Re: [racket-users] struct-info

2019-02-12 Thread Shu-Hung You
On Tue, Feb 12, 2019 at 10:04 AM David Storrs wrote: > > Could someone point me to the FM on how to properly use struct-info? > For the life of me, I cannot get anything except (values #f #t) out of > it. I see that: > > 1) struct-info only works with struct types that are under the control > of

Re: [racket-users] Fully expanded programs grammar: print-values

2019-02-06 Thread Shu-Hung You
On Wed, Feb 6, 2019 at 9:42 AM 'Paulo Matos' via Racket Users < racket-users@googlegroups.com> wrote: > > > > On 06/02/2019 16:00, Shu-Hung You wrote: > > print-values is a normal identifier introduced by the racket/base's > > macro module-begin. It

Re: [racket-users] Fully expanded programs grammar: print-values

2019-02-06 Thread Shu-Hung You
print-values is a normal identifier introduced by the racket/base's macro module-begin. It is a (private) function defined in racket/private/modbeg. On Feb 6, 2019 5:02 AM, "'Paulo Matos' via Racket Users" < racket-users@googlegroups.com> wrote: > Hi, > > The docs[1] give a grammar for fully expa

Re: [racket-users] Re: Redex: making a #lang with native lambda, app, etc.

2019-01-03 Thread Shu-Hung You
Deferring everything to runtime could avoid macros as much as possible. You can implement input parsing as a function and use the macro only to glue things together. #lang racket/base (require (for-syntax racket/base) syntax/parse/define redex/reduction-semantics) (provide (ren

Re: [racket-users] Re: Why enter/run a submodule in the REPL?

2018-12-13 Thread Shu-Hung You
Hi Stephan, The "submodules to run" drop-down menu lets you choose which submodules will be executed when you click the "Run" button. For example, if you have a main submodule and a test submodule, DrRacket will run those 2 submodules by default. You can avoid running tests in the test submodule b

[racket-users] (pict-snip%) Write: cannot marshal value that is embedded in compiled code value

2018-12-10 Thread Shu-Hung You
Is this some expected behavior? 1. Open DrRacket and run: #lang racket/base (require pict) (circle 50) 2. Copy the output. Open a new tab in DrRacket and paste the pict-snip%. 3. This error message showed up at the bottom: ``write: cannot marshal value that is embedded in compiled code value: (

[racket-users] (pict-snip%) Write: cannot marshal value that is embedded in compiled code value

2018-12-10 Thread Shu-Hung You
Is this some expected behavior? 1. Open DrRacket and run: #lang racket/base (require pict) (circle 50) 2. Copy the output. Open a new tab in DrRacket and paste the pict-snip%. 3. An error message showed up at the bottom, similar to this https://i.imgur.com/5BnTWP0.png Despite the error message

Re: [racket-users] Loggers that don't prepend?

2018-11-26 Thread Shu-Hung You
I think it depends on the code that logs the message, not the logger. In the log-message function, the topic and the prefix-message? arguments together control whether the message will be prefixed by the topic and ": " or not. On Mon, Nov 26, 2018 at 5:00 PM David Storrs wrote: > > Is there a way

Re: [racket-users] Obtain use-site source information

2018-11-21 Thread Shu-Hung You
Thanks! However, I am trying to avoid changing USE. The trouble is that there are too many macros using X that I don't understand, and these macros themselves are more than one layers deep. It is nearly impossible to thread the syntax property through the macros.On Wed, Nov 21, 2018 at 7:30 PM Matt

[racket-users] Obtain use-site source information

2018-11-21 Thread Shu-Hung You
source information of B and C? Currently, the only information I can get is the client module that uses USE, obtained by checking (current-module-declare-name) at expansion time in X. Shu-Hung -- You received this message because you are subscribed to the Google Groups "Racket Users" gr

Re: [racket-users] One macro -> N defined functions

2018-11-20 Thread Shu-Hung You
The begin form can encapsulate multiple definitions like this: (require (for-syntax racket/sequence racket/syntax) syntax/parse/define) (define-simple-macro (define-asserts predicate:id ...) #:with (assert-name ...) (for/list ([id (in-syntax #'(predicate ...))])

Re: [racket-users] Is there a way to eval a custom language from inside a module... without instantiating modules multiple times?

2018-11-16 Thread Shu-Hung You
On Fri, Nov 16, 2018 at 12:43 PM Andrew Wilcox wrote: > > I'd like to be able to eval a custom language from inside a module... without > instantiating modules multiple times. > > With the help of Matthew Butterick, I've gotten this far: > > ; runtime.rkt > #lang racket > > > (printf "This is run

Re: [racket-users] Re: reporting contract violations in executable programs

2018-11-01 Thread Shu-Hung You
Thanks for catching this! This is a bug in the setup/dirs library, which the contract system transitively depends on to compute the path in the error message. I opened a pull request and let's see how it goes (#2352). On Thu, Nov 1, 2018 at 5:23 PM Alex Harsanyi wrote: > > > > On Thursday, Novembe

Re: [racket-users] confusion about call-with-current-continuation

2018-10-26 Thread Shu-Hung You
vide-by-zero? > (lambda (exn) (println "div by 0"))]) > (saved-k 0)) ; wrapped in "prompt 4" > > (println 'hello2) ; wrapped in "prompt 5" > > ) > > Since the continuation executed in "prompt 4", why I

Re: [racket-users] confusion about call-with-current-continuation

2018-10-25 Thread Shu-Hung You
FWIW here's the part in the document that could be helpful: 1. The section in the Guide that talks about the concept of prompts and their usage in the continuation in Racket: https://docs.racket-lang.org/guide/prompt.html The prompt is kind of like a mark on the continuations that lets the control

Re: [racket-users] handin-server: reader used in checker modules

2018-10-17 Thread Shu-Hung You
On Wed, Oct 17, 2018 at 1:12 PM Jordan Johnson wrote: > > > On Oct 17, 2018, at 10:35, Matthias Felleisen wrote: > > (check-expect (+ 10 .25) 10.25) > > errors with check-expect’s message about not comparing inexact numbers, but > in DrRacket+BSL the decimals are treated as exact numbers. > > Wh

Re: [racket-users] Racket-on-Chez snapshots

2018-10-01 Thread Shu-Hung You
Here! http://www.cs.utah.edu/~mflatt/racket-on-chez-jan-2018/ Also a few days algo there were some more updates at RacketCon and Scheme Workshop. On Mon, Oct 1, 2018 at 1:08 PM Brett Gilio wrote: > > > Philip McGrath writes: > > In light of > > the promising outlook for Chez replacing the current

Re: [racket-users] MIT/Chicken/Chibi Scheme style ir-macro-transformer in Racket

2018-08-29 Thread Shu-Hung You
I should've been clear that the loop example was taken from the Chicken scheme wiki. Same for the while example mentioned in the email: https://wiki.call-cc.org/man/4/Macros#ir-macro-transformer Using the syntax->datum here would drop lexical information though; if the syntax object given to the m

Re: [racket-users] MIT/Chicken/Chibi Scheme style ir-macro-transformer in Racket

2018-08-29 Thread Shu-Hung You
I think the following program illustrates the idea, though it doesn't really work: #lang racket (begin-for-syntax (define (syntax-pair->cons stx) (define datum (syntax-e stx)) (cond [(list? datum) (map syntax-pair->cons datum)] [(pair? datum) (cons (syntax-pair

Re: [racket-users] Where to put scribblings in 'multi package?

2018-08-29 Thread Shu-Hung You
The gui-lib might be an example. It provides modules spanning different collections such as racket/gui, framework/ and mrlib/. https://github.com/racket/gui/tree/master/gui-lib On Wed, Aug 29, 2018 at 7:13 AM, Erich Rast wrote: > On Wed, 29 Aug 2018 06:46:49 -0500 > Philip McGrath wrote: > > >>

[racket-users] In Redex, how to to specify mutually-recursive bindings (#:refers-to)?

2018-08-23 Thread Shu-Hung You
Is it possible to specify mutually-recursive scope in Redex without an extra layer of nesting expression? I found this example for letrec: https://github.com/racket/redex/blob/master/redex-examples/redex/examples/letrec.rkt#:34 34 #:binding-forms ... 37 (letrec ([x e_x] ...) #:refers-to (shadow

Re: [racket-users] Converting bulleted list to s-expression?

2018-08-17 Thread Shu-Hung You
The markdown package by Greg Hendershott provides a parser that create HTML like xexprs from a string. The rest would be easy. https://docs.racket-lang.org/markdown/index.html On Fri, Aug 17, 2018 at 8:31 PM, Andrew J wrote: > Hi. In a little side project, I'm looking for an simple Racket-y wa

Re: [racket-users] How to handle define forms in a scribble-like language

2018-08-17 Thread Shu-Hung You
I would try make-wrapping-module-begin too. Basically, it wraps all module-level forms that "calculates something" with the syntax object you gave it. For example, the following program ;; some-language.rkt #lang racket (provide (except-out (all-from-out racket) #%module-begi

Re: [racket-users] Do I need macros to flag unbound identifiers as failing unit tests?

2018-08-11 Thread Shu-Hung You
Would convert-syntax-error and convert-compile-time-error work? Sure they are macros, but wrapped up in a nice way. https://docs.racket-lang.org/syntax/macro-testing.html On Sat, Aug 11, 2018 at 11:00 AM, Sage Gerard wrote: > Hi all, > > Still working the koans project and am hitting a design s

Re: [racket-users] Re: Question about style

2018-08-11 Thread Shu-Hung You
For small expressions it probably does not matter, but suitably naming intermediate expressions is definitely a good approach as it `explains' the code. Also, replacing let* by define can reduce nesting level. These 2 points are suggested in the style guide 4.2 and 4.4: https://docs.racket-lang.or

Re: [racket-users] How to limit memory usage and raise out-of-memory error?

2018-08-10 Thread Shu-Hung You
ble event > for custodian shutdown. > > At Fri, 10 Aug 2018 15:27:07 -0500, Shu-Hung You wrote: >> I'm running a thread with memory limit using custodian-limit-memory. >> How do I reliably detect whether the thread I'm running was terminated >> normally or aborted

[racket-users] How to limit memory usage and raise out-of-memory error?

2018-08-10 Thread Shu-Hung You
I'm running a thread with memory limit using custodian-limit-memory. How do I reliably detect whether the thread I'm running was terminated normally or aborted by custodian shutdown? Plus, is it possible to obtain the context at the time the memory limit was exceeded? I can think these two: 1. Us

Re: [racket-users] bf "module: initial import is not a well-formed module path"

2018-08-09 Thread Shu-Hung You
On Thu, Aug 9, 2018 at 3:42 PM, Zeta Convex wrote: > > > On Thursday, 9 August 2018 21:34:16 UTC+1, Shu-Hung You wrote: >> >> Change the first few lines of lang/reader.rkt to: >> >> #lang s-exp syntax/module-reader >> bf/language >> #:read my-read >

Re: [racket-users] bf "module: initial import is not a well-formed module path"

2018-08-09 Thread Shu-Hung You
Change the first few lines of lang/reader.rkt to: #lang s-exp syntax/module-reader bf/language #:read my-read #:read-syntax my-read-syntax ;; ... And just install the entire directory as a package using raco pkg install. This could take a while. If you want to make it faster, just skip building t

Re: [racket-users] DrRacket prefs?

2018-05-24 Thread Shu-Hung You
Hi Stephen, Running (find-system-path 'pref-file) in the REPL shows the path to the preference file. Inside the file there's one line like: (plt:framework-pref:framework:display-line-numbers #t) I don't know if directly copying the pref file to another computer would work but perhaps worth a try

Re: [racket-users] Arity-error for Handin Checker

2018-05-12 Thread Shu-Hung You
Hi James, If you use (check-deadline) in the checker, the config file needs to contain the deadline of the assignment. If the deadline configuration is not found, this error would show up. For example, in you have this config, ((active-dirs ("directoryA")) (inactive-dirs ...) (deadline ( (

Re: [racket-users] Problems with dynamic loading and `raco exe` executables

2018-05-07 Thread Shu-Hung You
#lang racket/load and (load PATH) are less idiomatic and more low-level in Racket. I don't know how did racket/load and load interact with ``raco exe'' but here's another way to make it work. Everything is placed inside modules. $ racket test.rkt ... ok ... $ raco exe ++lib racket/base/lang/read

Re: [racket-users] Any place to get keywords and constants of Racket?

2018-05-05 Thread Shu-Hung You
Here's a list of *some* keywords and regular expressions used by DrRacket, from line 387 to line 477: https://github.com/racket/gui/blob/master/gui-lib/framework/private/main.rkt#L387 On Sat, May 5, 2018 at 9:44 AM, piv det wrote: > I want to write a Racket mode for ace, > > Relate issue: https

Re: [racket-users] char-utf-8-length signature is surprising

2018-05-03 Thread Shu-Hung You
Looks like the implementation of char-utf-8-length returns values fitting the "FSS-UTF (1992) / UTF-8 (1993)" table in https://en.wikipedia.org/wiki/UTF-8#History. Not sure what's the standard UTF-8 encoding.. /* racket/src/char.c */ static Scheme_Object *char_utf8_length (int argc, Scheme_Object

[racket-users] Redex trace/ps doesn't produce edges

2018-04-28 Thread Shu-Hung You
Hello everyone, I try to save the traces generated by Redex to an image. However, the arrows between the expressions don't show up in the result. I tried some combinations of #:x-spacing, #:edge-labels? and #:layout to let the arrows showed up in trace, but the edges remain hidden when I ran trac

Re: [racket-users] Re: [racket/racket] bc5556: raco pkg update: add `---unclone` as a kind of ali...

2018-04-25 Thread Shu-Hung You
This is awesome! I never knew that un-cloning can be done by using --lookup. Shu-Hung On Wed, Apr 25, 2018 at 12:35 PM, 'John Clements' via Racket Users wrote: > YAY! > > I can *never* remember this flag. > > Many thanks, > > John > >> On Apr 25, 2018, at 9:32 AM, Matthew Flatt wrote: >> >> Br

Re: [racket-users] let-syntax example?

2018-04-03 Thread Shu-Hung You
Hi Keven, Here's an example: #lang racket (let-syntax ([a (lambda (stx) (printf "expansion time: stx = ~a\n" stx) #'3) ]) a) However, I would suggest to start at least from syntax objects and macro transformers in the guide and use defin

Re: [racket-users] Struct general question

2018-03-26 Thread Shu-Hung You
For controlling custom printing of a struct, you can use `gen:custom-write` generic interface. An example is like the use of make-cosntructor-style-printer: https://docs.racket-lang.org/reference/structutils.html#%28def._%28%28lib._racket%2Fstruct..rkt%29._make-constructor-style-printer%29%29 Unde

Re: [racket-users] A very simple #lang

2018-01-25 Thread Shu-Hung You
The explanation of the 5-argument read and 6-argument read-syntax is here, starting from the 3rd paragraph of this subsection: https://docs.racket-lang.org/reference/reader.html#%28part._parse-reader%29 The 5 (or 6) arguments version read accepts extra source location information. However, this ve

Re: [racket-users] Byte Order Mark: alter display of symbols containing nonprinting characters?

2017-12-27 Thread Shu-Hung You
(Interned) symbols that have the same printed form but are not equal to each other already exist tho; the symbols produced by string->unreadable-symbol are not equal? to their counterparts produced by the reader, but nevertheless have the same printed representation. Shu-Hung On Wed, Dec 27, 2017

Re: [racket-users] structs vs classes

2017-12-07 Thread Shu-Hung You
I'm not sure whether the following is a good idea, but it more or less works. The impersonate-struct function allows one to redirect the some or all of accessor and mutator functions on *individual struct instances*. If the actual constructor is hidden from the user and only a ``smart'' constructor

Re: [racket-users] namespace-variable-value thinks functions are bound to syntax

2017-10-30 Thread Shu-Hung You
Yes, because keyword functions expand to macro definitions that try to optimize keyword applications. namespace-require and namespace-variable-value are relatively low-level operations on modules and namespaces. Using dynamic-require could be a bit easier: #lang racket (module p racket (provid

Re: [racket-users] DrR compilation progress bar

2017-10-28 Thread Shu-Hung You
I think printing which file is currently being loaded can also help, like the logs given by enter! #:verbose. These logs can also be printed to the interaction window and be erased after the loading process is finished. This can let the user know that something is actually running. --Shu-Hung On

Re: [racket-users] Confusing typed/racket error message

2017-10-03 Thread Shu-Hung You
Hi Taahir, The keyword is #:replacement? instead of #:replacement (note the question mark). I don't know enough Typed Racket to understand that error message tho, sorry. Cheers, Shu-Hung On Tue, Oct 3, 2017 at 1:40 AM, Taahir Ahmed wrote: > Hi, > > I have been implementing some toy problems in

Re: [racket-users] ~literal vs ~datum

2017-09-11 Thread Shu-Hung You
I think the case here is a little subtle. The syntax object #'(define x y) has actually gone through expansion, but Racket's new expansion model will prune this syntax object's local scopes [1]. One could use #:local [2] in this case to see the difference: > (syntax-parse (let ([define 'something-

Re: [racket-users] How to load net/jwt

2017-09-10 Thread Shu-Hung You
This command should install the net-jwt library for you: raco pkg install net-jwt --Shu-Hung On Mon, Sep 11, 2017 at 9:15 AM, Chongkai Zhu wrote: > Hi all, > > https://docs.racket-lang.org/jwt/index.html > > It seems I just need to (require net/jwt) in racket 6.10 and everything > should work.

Re: [racket-users] Suppress print lines from required modules

2017-08-27 Thread Shu-Hung You
Parameterizing current-output-port to (open-output-string) redirects the output to a string. Something along the line of (open-output-file "/dev/null") sounds a bit better but I'm not sure how to create a discard-everything output port. (define ns (make-base-namespace)) (parameterize ([current-na

Re: [racket-users] Re: Readers and Namespaces

2017-08-18 Thread Shu-Hung You
If you are implementing a new language, this can be done by delegating the "=-to-let" work to the macro-expander and let the reader simply parenthesizing the input into s-expression form. In this approach, we don't need to worry about being hygienic in the reader since the actual work is done by th

Re: [racket-users] Re: Racket from Homebrew has trouble when upgrading

2017-08-07 Thread Shu-Hung You
>From this thread, it seems that the original formula it not actively maintained. But the thread also mentions `cask`, probably worth a try. https://groups.google.com/forum/#!msg/racket-dev/Zyl9m8UWvp0/GVDcHVkWAwAJ Best, Shu-Hung On Mon, Aug 7, 2017 at 6:23 PM, wrote: > It seems I got it workin

Re: [racket-users] Correctly executing a source file from embedded Racket

2017-07-26 Thread Shu-Hung You
Hi Thomas, I tried following Matthew's suggestions to attach my-lang and use dynamic-require. Turns out that works pretty well! And then there's even no need to setup collection path since everything loads from compiled byte-code. https://gist.github.com/shhyou/aa2adaf7e1b7d548783cee352c3230a9 Th

Re: [racket-users] Correctly executing a source file from embedded Racket

2017-07-25 Thread Shu-Hung You
Hi Thomas, I think the program is more of Racket programming setup rather than embedding Racket. When start a Racket program on our own, we have to setup the environment correctly. Here is my test program that can load an external program and the accompanying commands (also attached at the end).

Re: [racket-users] Can raco distribute produce a single executable?

2017-02-20 Thread Shu-Hung You
Sorry, I saw that you're already using raco exe and raco distribute. So is the problem related to some DLL issue on Windows? Best, Shu-Hung On Mon, Feb 20, 2017 at 1:19 PM, Shu-Hung You wrote: > https://docs.racket-lang.org/raco/exe.html > Is raco exe in this page what you want

Re: [racket-users] Can raco distribute produce a single executable?

2017-02-20 Thread Shu-Hung You
https://docs.racket-lang.org/raco/exe.html Is raco exe in this page what you want? Just type > raco exe q.rkt And this command will produce a single executable. Now we can now run > ./q q: expects 1 on the command line, given 0 arguments Best, Shu-Hung On Mon, Feb 20, 2017 at 1:12 PM, lu wro

Re: [racket-users] Why is this exception giving me an arity error?

2017-02-17 Thread Shu-Hung You
This works completely fine on a fresh racket REPL: > (exn:fail:bmtc:unknown-user "message" (current-continuation-marks) "bob") (exn:fail:bmtc:unknown-user "message" # "bob") I guess there might be some inconsistency in REPL states. Starting a fresh racket should work, or maybe use (enter! "./modu

[racket-users]

2016-12-19 Thread Shu-Hung You
x 1)) imp-prop:a "a value")) (define unimpersonated (impersonate-procedure impersonated #f)) (unimpersonated 10) ;=> 19 (impersonator? unimpersonated) ;=> #t (imp-prop:a? unimpersonated) ;=> #t (imp-prop:a-get unimpersonated) ;=> "a value" Best, Shu-Hung -- Yo

Re: [racket-users] Where is "PLT Games.exe" source code?

2016-11-23 Thread Shu-Hung You
Hi Ken, do you mean this? https://github.com/racket/games --Shu-Hung On Wed, Nov 23, 2016 at 2:02 PM, Ken Biondi wrote: > Where is the source code for "PLT Games.exe"? I unsuccessfully searched > github for it. > > -- > You received this message because you are subscribed to the Google Groups

Re: [racket-users] How to 'apply' a function with optional parameters?

2016-10-29 Thread Shu-Hung You
Hi Meino, Could you give an example of lst or line? Unlike string-append, most of the time string-join doesn't really require an 'apply'. As we can see: > (string-append "a" "b" "c") "abc" > (string-join '("a" "b" "c") ":") "a:b:c" While string-append takes all its arguments and concatenates the

[racket-users] Re: Compare parts of string or compare with wildcard.

2016-10-28 Thread Shu-Hung You
Hi Ken, string-prefix? does exactly what you want. > (define a "this") (define b "that") (define c "thisandthat") > (string-prefix? c a) #t > (string-prefix? c b) #f https://docs.racket-lang.org/reference/strings.html#%28def._%28%28lib._racket%2Fstring..rkt%29._string-prefix~3f%29%29 Best, Shu-H