Re: [racket-users] making a language that can return the body of a function
Try to start with this: #lang racket ;; new-lang.rkt (provide #%app #%datum #%top-interaction (rename-out (new-lambda lambda) (new-mb #%module-begin))) (define-syntax (new-lambda stx) (syntax-case stx () [(_ (x ...) e ...) #'(lam '(x ...) '(e ...) (lambda (x ...) e ...))])) (struct lam (parameters bodies closure) #:property prop:procedure 2) (define-syntax (new-mb stx) (syntax-case stx () [(_ e ...) #'(#%module-begin (let ([v e]) (if (lam? v) `(lambda ,(lam-parameters v) ,@(lam-bodies v)) v)) ...)])) ;; - - - #lang s-exp "new-lang.rkt” ;; new-lang-client.rkt ((lambda (x) x) (lambda (y) y)) > On May 23, 2017, at 10:03 PM, Vityouwrote: > > On Tuesday, May 23, 2017 at 7:17:18 PM UTC-6, Matthias Felleisen wrote: >> Why do you interpret S-expressions instead of re-mapping lambda and #%app? >> >> >> >> >> >>> On May 23, 2017, at 9:14 PM, Vityou wrote: >>> >>> I might be able to do something like this, but what I'm looking for is >>> something that will be able to show the variables available to it in >>> adition to its source. I'll probable have to do something like what you >>> did with the struct accept add a field with its available variables and >>> modify #%app to add to its known variables. >>> >>> -- >>> 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. >>> For more options, visit https://groups.google.com/d/optout. > > I dont know what I could map lambda to that would let it retain and print its > known variables besides a list. -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] making a language that can return the body of a function
On Tuesday, May 23, 2017 at 7:17:18 PM UTC-6, Matthias Felleisen wrote: > Why do you interpret S-expressions instead of re-mapping lambda and #%app? > > > > > > > On May 23, 2017, at 9:14 PM, Vityouwrote: > > > > I might be able to do something like this, but what I'm looking for is > > something that will be able to show the variables available to it in > > adition to its source. I'll probable have to do something like what you > > did with the struct accept add a field with its available variables and > > modify #%app to add to its known variables. > > > > -- > > 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. > > For more options, visit https://groups.google.com/d/optout. I dont know what I could map lambda to that would let it retain and print its known variables besides a list. -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] DrRacket has become unusable: freezes almost immediately
> After the `killall` from tty2, did the shell you started DrRacket from have > any output? > > Thanks for helping us investigate! > > Vincent Unfortunately not. After going to tty2, entering "killall drracket" and back to tty1, the terminal was as I left it, with just the command "drracket" shown as the previous command. I'm happy to check logs, but I'm not sure which ones... It also may be a matter of a library not behaving properly: sometimes my system (which runs on a laptop) doesn't wake up properly from a hibernation. I should probably check with a reboot (which I'd rather avoid if possible), or a logout from my KDE session and a new login. I'll do some more fiddlin'... until then it's back to Emacs and Geiser! -Alasdair -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] making a language that can return the body of a function
I might be able to do something like this, but what I'm looking for is something that will be able to show the variables available to it in adition to its source. I'll probable have to do something like what you did with the struct accept add a field with its available variables and modify #%app to add to its known variables. -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] making a language that can return the body of a function
I think you will probably want to define an applicable struct type with custom printing behavior and then replace Racket's lambda with your own macro to create instances of that struct type. I think what you want may be more complex than this, but here's an example that simply carries along its own source text: #lang racket (require (for-syntax syntax/parse)) (struct my-lambda-record (name proc) #:property prop:custom-print-quotable 'never #:methods gen:custom-write [(define (write-proc this out mode) (print (my-lambda-record-name this) out 1))] #:property prop:procedure (struct-field-index proc)) (define-syntax (my-lambda stx) (syntax-parse stx [(_ (formal:id) body:expr) #`(my-lambda-record '#,stx (lambda (formal) body))])) Then for example: > (my-lambda (x) (my-lambda (y) x)) (my-lambda (x) (my-lambda (y) x)) -Philip On Tue, May 23, 2017 at 4:10 PM, Vityouwrote: > In lambda calculus, the function is the only datatype, so it would be > useful to see the body of a function when it is returned in some expression > in the repl (so you can see what number was returned or some other > encoding). I have got this working by making a language where the reader > turns the file into a list and #%module-begin just prints the result of > applying an eval function that works with lists to the list from the > reader. This works quite well: > > > x > x > > ((lambda (x) (lambda (y) x)) f) > (function (lambda (y) x) ((x f))) > > > but I was thinking of including some things like a non-recursive define > and provide and require, but the current list based system I have right now > won't work. Is there any way that I could have racket print its own > lambdas like mine above? Or is there any way to achieve the same effect > (the effect being able to print lambdas like above and use define require > and provide). I attached the expander of the list based lambda calculus if > you want to look at it. > > -- > 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. > For more options, visit https://groups.google.com/d/optout. > -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Convert mouse coordinates in mouse-event% to window coordinates? And also for snip%...
Hi Rast the mouse event object of editor% and snip% is always the one passed to the on-event method of editor-canvas% (that's why event handlers of snip% have lots of extra arguments to provide you the location information, racket/snip do the computing for you). When it is used with a snip% instance directly, you have to check the docs to see the proper way to use it correctly. Another thing you should take care is that, the event object itself is not able to tell you the snip%s' enter and leave stats. A1 & A2: You have get-top-level-windows and get-current-mouse-state. (But the Question 1 is not necessary for your requirements here). A3: You have get-snip-location, local-to-global, and client->screen. On Tue, May 23, 2017 at 10:24 PM, Erich Rastwrote: > Hi, > > For me personally, coordinates are probably the most unintuitive aspect > of Racket's GUI management. The problem comes up again and again, and I > never get it right, so maybe someone can clarify this once and for all. > > I have a mouse-event% in on-event of a snip% and would like to display > a floating frame% just below the mouse. > > Question 1: What is the right way to obtain the window in a potentially > nested hierarchy of editors? I'm currently using: > > (define top-window (and-let* ((canvas (get-canvas)) >(top (send canvas get-top-level-window))) > top)) > > is that correct? > > Question 2: How do I obtain the right coordinates for the frame% that I > would like to show below the mouse? > > I assume it has something to do with top-window above, but how do I > convert from the coordinates of the mouse-event to the 'right' > coordinates? Currently, the frame% appears offset about 20 to 20 pixels > below the top-window's top-left corner and not at all where the mouse > is located. > > Are the mouse-event coordinates relative to the editor? Or relative to > the snip within the editor? How do I convert them? > > Question 3: Suppose I want to do the same with a snip% displayed in a > text% with one editor-canvas%, i.e., show a floating window just below > the snip%. Use cases: tooltips, spell corrections, etc. > > How do I do that? > > Thanks a lot in advance! > > Best, > > Erich > > > > -- > 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. > For more options, visit https://groups.google.com/d/optout. > -- 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. For more options, visit https://groups.google.com/d/optout.
[racket-users] making a language that can return the body of a function
In lambda calculus, the function is the only datatype, so it would be useful to see the body of a function when it is returned in some expression in the repl (so you can see what number was returned or some other encoding). I have got this working by making a language where the reader turns the file into a list and #%module-begin just prints the result of applying an eval function that works with lists to the list from the reader. This works quite well: > x x > ((lambda (x) (lambda (y) x)) f) (function (lambda (y) x) ((x f))) but I was thinking of including some things like a non-recursive define and provide and require, but the current list based system I have right now won't work. Is there any way that I could have racket print its own lambdas like mine above? Or is there any way to achieve the same effect (the effect being able to print lambdas like above and use define require and provide). I attached the expander of the list based lambda calculus if you want to look at it. -- 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. For more options, visit https://groups.google.com/d/optout. expander.rkt Description: Binary data
Re: [racket-users] Can't get Dr Racket Documentation
Ah -- my apologies: the command was supposed to be only on a single line with only a single space after the word "location" and the open quote character. Can you try that again? Robby On Tue, May 23, 2017 at 10:01 AM j.da...@t-online.dewrote: > Hello, > > thank you! > > I get: > > Last login: Tue May 23 10:53:08 on console > Juergens-iMac:~ jdabel$ /usr/bin/osascript -e 'open location > > "file:///Applications/Racket%20v6.9/doc/index.html"' > 0:13: execution error: «script» versteht die Nachricht „open location“ > nicht. (-1708) > Juergens-iMac:~ jdabel$ > > Jürgen > > -Original-Nachricht- > Betreff: Re: [racket-users] Can't get Dr Racket Documentation > Datum: 2017-05-23T15:36:15+0200 > Von: "Robby Findler" > An: "Jürgen Dabel" > > What happens if you open up a terminal window and paste this command in? > >/usr/bin/osascript -e 'open location > "file:///Applications/Racket%20v6.9/doc/index.html"' > > Robby > > > On Sun, May 21, 2017 at 4:34 AM, wrote: > > I get an error when trying to get Help Desk or Dr Racket Documentation > from the menu. I get following error: > > > > Thank you > > Juergen Dabel > > Schrobenhausen > > Germany > > > > -- > > 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. > > For more options, visit https://groups.google.com/d/optout. > -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] DrRacket has become unusable: freezes almost immediately
On Tue, 23 May 2017 06:35:58 -0500, Alasdair McAndrew wrote: > > On Tuesday, 23 May 2017 21:06:17 UTC+10, Robby Findler wrote: > > If you start DrRacket from the shell, trigger the bad behavior and then > > type control-c in the shell, do you get any output? > > > > > > Robby > > > Thanks for the suggestion - which I had in fact tried, to no avail. DrRacket > froze, and the only way out of it was via tty2. After the `killall` from tty2, did the shell you started DrRacket from have any output? Thanks for helping us investigate! Vincent -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Contracts for generic interfaces (or struct type properties?)
Hi Philip, I don't think you can express the contract boundary you have in mind using the generics library as it is. The blame you see for both contracts makes sense. In the first case, `string-server` is not protecting itself from bad inputs (uses `any/c`) yet promises to return a string. It rightly gets blamed when that doesn't happen. In the second case, `string-server` does protect itself (using `can-be-string/c`), but it protects itself against its callers, who now have the responsibility to pass it something reasonable. It doesn't (passes the `buggy` struct along), so it rightly gets blamed. To get the contract boundary that you want, I think you'd want to wrap the `buggy` constructor with a contract that makes it commit to producing a valid `can-be-string`. You could do this either when you export it from the `buggy` module, or by "laundering" it through a submodule before getting it to the main module. That way, it should end up being blamed. This is not a great solution, because you'd have to do this for every instance of the generic interface, but the class of boundaries you have in mind cannot currently be described, I think. Vincent On Mon, 22 May 2017 22:31:25 -0500, Philip McGrath wrote: > > I'm running into trouble in trying to give contracts to methods from generic > interfaces (in the sense of racket/generic) that assign blame to the > implementor of a bad method implementation. This seems like it's probably a > common problem, so I'm > hoping a solution exists. > > For an example, consider the following: > > #lang racket > > (module string-server racket > (require racket/generic) > (provide gen:can-be-string > can-be-string? > (contract-out > [to-string > (-> any/c > string?)] > )) > (define-generics can-be-string > (to-string can-be-string) > #:fast-defaults > ([string? > (define (to-string str) > str)]))) > > (module buggy racket > (require (submod ".." string-server)) > (provide (struct-out buggy)) > (struct buggy () > #:methods gen:can-be-string > [(define (to-string this) > 'not-a-string)])) > > (require (submod "." string-server) > (submod "." buggy)) > > (to-string (buggy)) > > This program raises an exception as expected, but blames the string-server > module rather than the buggy module. > > The string-server module can deflect blame from itself by changing the > contract of to-string to > (-> (can-be-string/c [to-string (-> any/c string?)]) string?), but the result > is even worse: now the error blames the enclosing module. > > The closest thing I've found to a solution is to abandon racket/generic and > use a struct type property with a guard that performs lots of checks and > eventually calls chaperone-procedure. Aside from being verbose and > error-prone (in that it requires > manually writing checks correctly rather than relying the contract system), > it also doesn't really address the problem of blame, since errors from e.g. > raise-arguments-error don't blame anything in particular. > > Is there a way to write the kind of contract I have in mind? > > Thanks, > Philip > > -- > 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. > For more options, visit https://groups.google.com/d/optout. -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Dr Racket crash 2-finger-scroll
You're running Windows 10 Creators Update? Unfortunately, we do not have a workaround. Microsoft has accepted my bug report, but that's all the feedback we have so far. You can find more information here: https://github.com/racket/racket/issues/1671 At Tue, 23 May 2017 07:36:54 -0700 (PDT), Edgar Maldonado wrote: > Dr Racket seems to crash on my windows laptop every-time I use the > two-finger-scroll. Not only does it crash the app, but also my entire laptop. > It then deletes everything I'm working on. I get the blue screen with the > stop > code UNEXPECTED_KERNEL_MODE_TRAP. > > Wondering what I can do to fix this issue. > > P.S. two finger scroll works anywhere but Dr Racket. > > -- > 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. > For more options, visit https://groups.google.com/d/optout. -- 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. For more options, visit https://groups.google.com/d/optout.
[racket-users] Dr Racket crash 2-finger-scroll
Dr Racket seems to crash on my windows laptop every-time I use the two-finger-scroll. Not only does it crash the app, but also my entire laptop. It then deletes everything I'm working on. I get the blue screen with the stop code UNEXPECTED_KERNEL_MODE_TRAP. Wondering what I can do to fix this issue. P.S. two finger scroll works anywhere but Dr Racket. -- 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. For more options, visit https://groups.google.com/d/optout.
[racket-users] Convert mouse coordinates in mouse-event% to window coordinates? And also for snip%...
Hi, For me personally, coordinates are probably the most unintuitive aspect of Racket's GUI management. The problem comes up again and again, and I never get it right, so maybe someone can clarify this once and for all. I have a mouse-event% in on-event of a snip% and would like to display a floating frame% just below the mouse. Question 1: What is the right way to obtain the window in a potentially nested hierarchy of editors? I'm currently using: (define top-window (and-let* ((canvas (get-canvas)) (top (send canvas get-top-level-window))) top)) is that correct? Question 2: How do I obtain the right coordinates for the frame% that I would like to show below the mouse? I assume it has something to do with top-window above, but how do I convert from the coordinates of the mouse-event to the 'right' coordinates? Currently, the frame% appears offset about 20 to 20 pixels below the top-window's top-left corner and not at all where the mouse is located. Are the mouse-event coordinates relative to the editor? Or relative to the snip within the editor? How do I convert them? Question 3: Suppose I want to do the same with a snip% displayed in a text% with one editor-canvas%, i.e., show a floating window just below the snip%. Use cases: tooltips, spell corrections, etc. How do I do that? Thanks a lot in advance! Best, Erich -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Can't get Dr Racket Documentation
What happens if you open up a terminal window and paste this command in? /usr/bin/osascript -e 'open location "file:///Applications/Racket%20v6.9/doc/index.html"' Robby On Sun, May 21, 2017 at 4:34 AM,wrote: > I get an error when trying to get Help Desk or Dr Racket Documentation from > the menu. I get following error: > > Thank you > Juergen Dabel > Schrobenhausen > Germany > > -- > 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. > For more options, visit https://groups.google.com/d/optout. -- 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. For more options, visit https://groups.google.com/d/optout.
[racket-users] Can't get Dr Racket Documentation
I get an error when trying to get Help Desk or Dr Racket Documentation from the menu. I get following error: Thank you Juergen Dabel Schrobenhausen Germany -- 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. For more options, visit https://groups.google.com/d/optout.
[racket-users] Racket Documentation
When trying to get the docs from the Dr Racket menu I get>: Juergen Dabel Schrobenhausen Germany -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] DrRacket has become unusable: freezes almost immediately
On Tuesday, 23 May 2017 21:06:17 UTC+10, Robby Findler wrote: > If you start DrRacket from the shell, trigger the bad behavior and then type > control-c in the shell, do you get any output? > > > Robby > Thanks for the suggestion - which I had in fact tried, to no avail. DrRacket froze, and the only way out of it was via tty2. -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] DrRacket has become unusable: freezes almost immediately
If you start DrRacket from the shell, trigger the bad behavior and then type control-c in the shell, do you get any output? Robby On Tue, May 23, 2017 at 5:11 AM Alasdair McAndrewwrote: > I have had no problem running DrRacket on linux, under KDE Plasma, until > now. But now it seems to crash constantly. All I need to do is: > > 1. Open it up from the KDE menu > 2. Open up the File menu > > and then it freezes, and also causes a system freeze, as it appears to be > using 100% of CPU (according to "top"). The only way to recover is to open > up tty2, and "killall drracket" and then go back to tty1, which on my > system is running X. > > Does anybody know how to get DrRacket to run again? > > -- > 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. > For more options, visit https://groups.google.com/d/optout. > -- 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. For more options, visit https://groups.google.com/d/optout.
[racket-users] DrRacket has become unusable: freezes almost immediately
I have had no problem running DrRacket on linux, under KDE Plasma, until now. But now it seems to crash constantly. All I need to do is: 1. Open it up from the KDE menu 2. Open up the File menu and then it freezes, and also causes a system freeze, as it appears to be using 100% of CPU (according to "top"). The only way to recover is to open up tty2, and "killall drracket" and then go back to tty1, which on my system is running X. Does anybody know how to get DrRacket to run again? -- 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. For more options, visit https://groups.google.com/d/optout.