[racket-users] returning GUI elements in function?

2019-07-08 Thread Travis Hinkelman
Hi All, I was playing around with creating a progress bar. The basic idea was straightforward. #lang racket/gui (define frame (new frame% [label "Progress Bar"] [width 300])) (define hpane (new horizontal-pane% [parent frame])) (define

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

2019-07-08 Thread Matthias Felleisen
We all are indeed at Racket school. The arguments for/against contracts have been made over and over again especially by Betrand Meyers, before we even introduced and studied the higher-order boundary-tied variant. + Contracts separate the core functionality of a service module from its as

[racket-users] Snip bug: "should have been overridden context"

2019-07-08 Thread Kshitij Sachan
I'm setting up a very simple snip class that is based on the example in the documentation ( https://docs.racket-lang.org/gui/editor-overview.html#%28part._snip-example%29 Section 5.4). I was able to generate a snip that is a circle that grows in size when the up arrow key is pressed. However

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] raise-argument-error missing list?

2019-07-08 Thread Greg Hendershott
I'll chime in only because some of the usual suspects who could best answer this might be busy with the Racket summer school this week. I believe that function contracts can be about as fast as the sort of checks you'd code by hand, provided that: - The parameter contracts are simple, flat, firs

Re: [racket-users] [racet-userx] Syntax Class Question

2019-07-08 Thread Kevin Forchione
> On Jul 8, 2019, at 10:50 AM, David Storrs wrote: > > > > On Mon, Jul 8, 2019 at 12:59 PM Kevin Forchione > wrote: > Hi guys, > I’ve noticed that the library provides *some* syntax classes: id, str, char, > expo… for various datatypes, but not all. Obviously bein

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

2019-07-08 Thread Kevin Forchione
> On Jul 8, 2019, at 10:41 AM, David Storrs wrote: > > Nothing specific that I'm aware of, but others could answer this better. If > there are then they're probably related to speed. > > Personally, I'm quite fond of them because they eliminate the need for a lot > of tests and make the cod

Re: [racket-users] [racet-userx] Syntax Class Question

2019-07-08 Thread David Storrs
On Mon, Jul 8, 2019 at 12:59 PM Kevin Forchione wrote: > Hi guys, > I’ve noticed that the library provides *some* syntax classes: id, str, > char, expo… for various datatypes, but not all. Obviously being such a > handy aspect of syntax-parse there’s probably a reason for this. Having > spent a f

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

2019-07-08 Thread David Storrs
Nothing specific that I'm aware of, but others could answer this better. If there are then they're probably related to speed. Personally, I'm quite fond of them because they eliminate the need for a lot of tests and make the code much more self-documenting. Function contracts are detailed here: h

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

2019-07-08 Thread Kevin Forchione
> On Jul 8, 2019, at 8:17 AM, David Storrs wrote: > > Note that in many cases it can be better to use a contract as opposed to an > explicit check. For example, you could replace this: > > (define (feed-animals cow sheep goose cat) > (if (not (eq? goose 'goose)) > (raise-argument-e

[racket-users] [racet-userx] Syntax Class Question

2019-07-08 Thread Kevin Forchione
Hi guys, I’ve noticed that the library provides *some* syntax classes: id, str, char, expo… for various datatypes, but not all. Obviously being such a handy aspect of syntax-parse there’s probably a reason for this. Having spent a few days trying to roll my own for procedure I have to suspect t

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

2019-07-08 Thread David Storrs
Staircase thought: I shouldn't have said 'precisely equivalent' since the text of the error message may differ. 'Semantically equivalent' is more correct. On Mon, Jul 8, 2019 at 11:17 AM David Storrs wrote: > Note that in many cases it can be better to use a contract as opposed to > an explici

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

2019-07-08 Thread David Storrs
Note that in many cases it can be better to use a contract as opposed to an explicit check. For example, you could replace this: (define (feed-animals cow sheep goose cat) (if (not (eq? goose 'goose)) (raise-argument-error 'feed-animals "'goose" 2 cow sheep goose cat) "fed the ani

Re: [racket-users] What's wrong with my code?

2019-07-08 Thread 曹朝
Alright, thank you very much. 在 2019年7月8日星期一 UTC+8上午3:50:18,Matthias Felleisen写道: > > > With some for/loops in TR you’re out of luck. The expansion are too > complex to type-check easily. > > > On Jul 7, 2019, at 10:24 AM, 曹朝 > wrote: > > This is a simple algorithm for compute the shortest edit