[racket-users] Capturing sets of options in a splicing syntax class?

2015-05-26 Thread Alexis King
When using syntax/parse, is there a good way to do something like this?

(define-splicing-syntax-class options
  (pattern (~seq (~or (~optional (~seq (~and #:a a?)))
  (~optional (~seq (~and #:b b?)))
  (~optional (~seq (~and #:c c?)))
  (~optional (~seq (~and #:d d?
 ...)
   #:attr a/b #'(a? b?)
   #:attr c/d #'(c? d?)))

When using the above syntax class to parse #'(#:a #:d #:b), then the a/b 
attribute should be #'(#:a #:b) and the c/d attribute should be #'(#:d). 
However, this doesn't work, of course, because if one of the options isn't 
defined, the attribute will be #f, and the attribute binding will fail.

I can get around that by doing something like this:

(define-splicing-syntax-class options
  (pattern (~seq (~or (~optional (~seq (~and #:a a?)))
  (~optional (~seq (~and #:b b?)))
  (~optional (~seq (~and #:c c?)))
  (~optional (~seq (~and #:d d?
 ...)
   #:attr a/b #`(#,@(if (attribute a?) #'(a?) #'())
 #,@(if (attribute b?) #'(b?) #'()))
   #:attr c/d #`(#,@(if (attribute c?) #'(c?) #'())
 #,@(if (attribute d?) #'(d?) #'()

But that's rather long-winded and verbose. Even better would be a way to group 
the clauses within the pattern, something like this:

(define-splicing-syntax-class options
  (pattern (~seq (~or (~and (~seq (~optional (~seq (~and #:a a?)))
  (~optional (~seq (~and #:b b?
a/b)
  (~and (~seq (~optional (~seq (~and #:c c?)))
  (~optional (~seq (~and #:d d?
c/d))
 ...)))

But that obviously doesn't work, and I'm not sure what it would do even if it 
compiled.

Anyway, is there a more concise way to do this? I know it's relatively easy 
using `template` from syntax/parse/experimental/template, but this is going 
into the Typed Racket code, so we're intentionally avoiding a dependency on 
that.

Alexis

-- 
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] Simple Interdependent Units?

2015-05-26 Thread Matthias Felleisen

On May 26, 2015, at 1:10 AM, Michael Tiedtke wrote:

 Sorry, ut I call it a workaround.


Please read up on programming language design. 

-- 
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] exn-string

2015-05-26 Thread WarGrey Gyoudmon Ju
I think user-friendly 500 page should be designed separately just as web
devs do for 404 page.
In practice, a user happens to meet an uncaught runtime exception, and he's
browsing a buggy website,
perhaps he do not have the will to report the problem, nor the way to
report it.
Finally, devs will fix it certainly by checking a place, say, logging
system, where saved this exception
rather than asking user for the screen snapshot.

So I think it's devs' fault if they forget to hide their exceptions.
This situation should never happen in a high-value project.



On Mon, May 25, 2015 at 11:16 PM, Greg Hendershott 
greghendersh...@gmail.com wrote:

 Maybe I'm over-thinking this and/or misunderstanding the use case, but:

 Should there maybe be a parameter to control whether exn-string
 returns anything interesting? And, should it be #f by default?


 Roughly, for example:

 ;; When current-exn-string-enabled? is #f -- the default --
 ;; exn-string simply returns error.
 ;;
 ;; (The idea here is that net apps shouldn't provide this information
 ;; by default, exn-string is probably being used to provide debug
 ;; info, and this should be enabled intentionally not by default.)
 (define current-exn-string-enabled? (make-parameter #f))

 ;; exn-string : (or/c exn any) - string
 (define (exn-string exn)
   (cond [(not (current-exn-string-enabled?)) error]
 [(exn? exn) (parameterize ([current-error-port
 (open-output-string)])
   ((error-display-handler) (exn-message exn) exn)
   (get-output-string (current-error-port)))]
 [else (format ~s\n exn


 Admittedly, just because there's a switch to turn it on and off,
 doesn't mean people will use it. (Source: Use the web for a week and
 encounter .NET apps deployed to show debug stack traces on error.)
 But there should be a switch, so that people can forget to use it. :)

 Admittedly, most Racket web apps are probably not high-value targets,
 today. But they ought to be someday, so why not plan for that?

 Again, I'm sorry if I'm over-thinking this.

 --
 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] exn-string

2015-05-26 Thread Jay McCarthy
For the purposes of the Web server, I don't think that's the right
thing to do. The right thing to do if you don't like the error display
is to change the arguments to #:servlet-loading-responder and
#:servlet-responder to print less, or just put with-handlers in your
servlet and do something else.

Jay

On Tue, May 26, 2015 at 1:39 PM, Tony Garnock-Jones to...@ccs.neu.edu wrote:
 On 05/25/2015 11:16 AM, Greg Hendershott wrote:
 Should there maybe be a parameter to control whether exn-string
 returns anything interesting? And, should it be #f by default?

 That's an interesting idea. I know of examples where Racket error
 reports have disclosed sensitive information. Such mistakes can be
 extremely subtle and difficult to anticipate, and even skilled,
 experienced engineers make them.

 Perhaps, if a parameter is a good idea (I'm not sure it is), when it is
 #f, exn-string could yield an instructive message such as

   #error redacted to avoid accidental information leak; see
 documentation for current-exn-string-enabled?

 plus suitable RED FONT DANGER TEXT in the documentation making it clear
 to users that they should think about the contexts in which the
 resulting strings will be published.

 Tony

 --
 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.



-- 
Jay McCarthy
http://jeapostrophe.github.io

   Wherefore, be not weary in well-doing,
  for ye are laying the foundation of a great work.
And out of small things proceedeth that which is great.
  - DC 64:33

-- 
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] exn-string

2015-05-26 Thread Jay McCarthy
Amen

On Tuesday, May 26, 2015, WarGrey Gyoudmon Ju juzhenli...@gmail.com wrote:

 I think user-friendly 500 page should be designed separately just as web
 devs do for 404 page.
 In practice, a user happens to meet an uncaught runtime exception, and
 he's browsing a buggy website,
 perhaps he do not have the will to report the problem, nor the way to
 report it.
 Finally, devs will fix it certainly by checking a place, say, logging
 system, where saved this exception
 rather than asking user for the screen snapshot.

 So I think it's devs' fault if they forget to hide their exceptions.
 This situation should never happen in a high-value project.



 On Mon, May 25, 2015 at 11:16 PM, Greg Hendershott 
 greghendersh...@gmail.com
 javascript:_e(%7B%7D,'cvml','greghendersh...@gmail.com'); wrote:

 Maybe I'm over-thinking this and/or misunderstanding the use case, but:

 Should there maybe be a parameter to control whether exn-string
 returns anything interesting? And, should it be #f by default?


 Roughly, for example:

 ;; When current-exn-string-enabled? is #f -- the default --
 ;; exn-string simply returns error.
 ;;
 ;; (The idea here is that net apps shouldn't provide this information
 ;; by default, exn-string is probably being used to provide debug
 ;; info, and this should be enabled intentionally not by default.)
 (define current-exn-string-enabled? (make-parameter #f))

 ;; exn-string : (or/c exn any) - string
 (define (exn-string exn)
   (cond [(not (current-exn-string-enabled?)) error]
 [(exn? exn) (parameterize ([current-error-port
 (open-output-string)])
   ((error-display-handler) (exn-message exn) exn)
   (get-output-string (current-error-port)))]
 [else (format ~s\n exn


 Admittedly, just because there's a switch to turn it on and off,
 doesn't mean people will use it. (Source: Use the web for a week and
 encounter .NET apps deployed to show debug stack traces on error.)
 But there should be a switch, so that people can forget to use it. :)

 Admittedly, most Racket web apps are probably not high-value targets,
 today. But they ought to be someday, so why not plan for that?

 Again, I'm sorry if I'm over-thinking this.

 --
 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
 javascript:_e(%7B%7D,'cvml','racket-users%2bunsubscr...@googlegroups.com');
 .
 For more options, visit https://groups.google.com/d/optout.




-- 
Jay McCarthy
http://jeapostrophe.github.io

   Wherefore, be not weary in well-doing,
  for ye are laying the foundation of a great work.
And out of small things proceedeth that which is great.
  - DC 64:33

-- 
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] Simple Interdependent Units?

2015-05-26 Thread Michael Tiedtke

Il giorno 26/mag/2015, alle ore 17.11, Matthias Felleisen ha scritto:

 
 On May 26, 2015, at 11:00 AM, Michael Tiedtke michael.tied...@o2online.de 
 wrote:
 
 
 Il giorno 26/mag/2015, alle ore 14.17, Matthias Felleisen ha scritto:
 
 
 On May 26, 2015, at 1:10 AM, Michael Tiedtke wrote:
 
 Sorry, ut I call it a workaround.
 
 
 Please read up on programming language design. 
 
 
 
 I consider the term programming language to be some kind of marketing label.
 Codings systems and their abstraction sometimes even capture concepts ...
 othertimes it's syntactic sugar.
 
 
 Please read up on programming language design. I am sorry for repeating 
 myself. 
 

Yes, they all start out with maths but I would base it on music with repeat 
instead of
loop just to eventually see a lot of playing cards on my virtual music rack. ;-)
Well strings might be useful, too.

-- 
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] Flower Garden: Open Flowers '[1 1]

2015-05-26 Thread Michael Tiedtke
This is a maintenance release. It's on PLaneT, too. But I can't load it ...

http://planet.racket-lang.org/display.ss?package=Open%20Flowers.pltowner=mti

-- 
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.


Open Flowers.plt
Description: Binary data
 

-- 
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.
Title: README



README

Table of Contents

1 Open Flowers (Revision '[1 1])
2 Description  Rules
3 NaL (Not a License)
4 Technical Note:
5 Source Tree Layout
6 Sketch: Object Relations / Data Structure
7 Sketch: Class Hierarchy
8 Message Passing (see Open Flowers.rkt)

8.1 Protocol: Game Rules
8.2 Protocol: Other Program Actions (see also Parallel Objects)
8.3 Protocol: Layout 
8.4 Protocol: Stateful Objects


9 Description of the User Interaction
10 Parallel Objects
11 Event Handling
12 Animations
13 Bugs and Maintenance




1 Open Flowers (Revision '[1 1])



This is the message passing approach to the patience solitaire game
Flower Garden.


This is the variant Flower Venus Garden with Laughing Flowers based
on a relaxed ruleset.  You can move only one card at time but from
anywhere to anywhere.  Sequences in the flower beds have to be
build by suit.  The foundations are built from ace to king but
cards can be moved back into the game. You can double click a card
and if possible it will find its place in the foundations. You can
place up to sixteen cards in the bouquet. There is a good chance of
winning the game.


(The layout of the bouquet, i.e. the reserve of cards at the bottom
of the table is done automatically but only after a card has been
moved successfully. Rethinking and correcting this is left as
exercise for the interested player.)




2 Description  Rules



One deck of 52 cards.


 from wikipedia
Thirty-six cards are dealt in to six columns, each containing six
cards. The columns are called the "flower beds" and the entire
tableau is sometimes called "the garden." The sixteen leftover
cards become the reserve, or "the bouquet."


The top cards of each flower-bed and all of the cards in the
bouquet are available for play. Cards can only be moved one at a
time and can be built either on the foundations or on the other
flower beds. The foundations are built up by suit, from Ace to King
(a general idea of the game is to release the aces first). The
cards in the garden, on the other hand, can be built down
regardless of suit and any empty flower bed can be filled with any
card. The cards in the bouquet can be used to aid in building, be
put into the foundations, or fill an empty flower bed.


The game is won when all cards end up in the foundations.
 end from wikipedia





3 NaL (Not a License)



This is free source code - free as in "free like a bird".


This is open source and marketing (which is a little bit like
gardening): if someone gives you a pen at no cost and you have to
refill it to write down you're favourite poem with it and someone
else sings it and the producer of that song makes a whole lot of
money with it then never forget: they could have used any pen to do
the job. Don't break my pencils!






4 Technical Note:



While it is written in a rather traditional way without mixins, traits
or an emphasis on surrogates it might contain ideas, concepts and
terms that go beyond today's message passing "customs". A new message
passing primitive "broadcast" and the term hub for certain classes are
consequences of thinking about the future of message passing, parallel
objects and one new program code abstraction system "to rule them all"
especially when it comes to open source and the user's ability to
adapt and program the shiny some thousand money units worth machine in
front of him. From LISP machines to BSD to Mach message passing
microkernel to NextStep to  but that is far away: for me it was
from QBASIC to RISC assembler to NetBeans to Dr. Racket to whatever
comes in handy.






5 Source Tree Layout



This implementation of Flower Garden started as one file and the one
file approach ended at about 1300 lines of text. Then some parts have
been cut out and are now called sections and the whole was renamed
"Open Flowers". Afterwards with features like the hint system and
additional animations the complexity has risen as have the
prerequisites on the side of the programmer to substantially change
the program.



  /Open Flowers/README.txt
This little text.
 
  /Open FLowers/info.rkt
PLT software package information.
 
  /Open Flowers/Open Flowers.rkt:
Classes: stack and subclasses, garden (program action 

Re: [racket-users] exn-string

2015-05-26 Thread Greg Hendershott
I was thinking the parameter could be a handy runtime switch,
defaulting to safe. However realistically there's probably a lot of
other ground to cover when it comes to debug vs. production
deployments. Maybe this needs a more comprehensive approach than
nibbling away one switch at a time.

Maybe a doc warning is sufficient: It is probably unwise to put this
information in a network response (like a web page) in production.

-- 
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] Generic collections in Racket

2015-05-26 Thread Alexis King
 Alexis, think of a lazy sequence as something that the rest of the program 
 will explore. In addition to a GUI-based exploration, I would love to see a 
 programmatic one. Imagine 
 
  (explore-lazy lazy-sequence:exp strictness-pattern:exp)
 
 where (the value of) strictness-pattern is a function that pokes around 
 lazy-sequence and displays. You could provide default strictness-pattern 
 values and you could even provide strictness-patterns that dump values into a 
 scrollable snip. But others could program their own strictness-patterns. The 
 key would be to keep it simple. 

I've thought about this some more since you sent me this message, and I've come 
up with a few potentially interesting ideas for inspecting sequence types. I 
may try and implement some of them to play with that idea.

To put it simply, I think it would be helpful to allow sequences to expose some 
information about themselves through optional method implementations that would 
be displayed and organized via inspection methods. I've already tried something 
like that in the form of `known-finite?` from gen:countable, and it would 
certainly be possible to include some additional methods for extracting 
sequence metadata. It might even be possible to use some of that metadata to 
produce a sequence-custom-write structure type property for default printing of 
sequence, similar to the property already exposed for contracts.

 Note that contracts for lazy sequences could also check via 
 strictness-patterns and memoize the exploration path. If the rest of the 
 program re-explores it's cached in the proxy and if it goes beyond that 
 exploration, consider it a contract violation.

I will note here that Racket streams automatically perform memoization, so once 
a stream has been evaluated, its elements are automatically cached. This itself 
has its tradeoffs (forcing the same sequence twice for the side-effects won't 
work), but it's probably what would be desired in the large majority of cases.

-- 
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] exn-string

2015-05-26 Thread Tony Garnock-Jones
On 05/25/2015 11:16 AM, Greg Hendershott wrote:
 Should there maybe be a parameter to control whether exn-string
 returns anything interesting? And, should it be #f by default?

That's an interesting idea. I know of examples where Racket error
reports have disclosed sensitive information. Such mistakes can be
extremely subtle and difficult to anticipate, and even skilled,
experienced engineers make them.

Perhaps, if a parameter is a good idea (I'm not sure it is), when it is
#f, exn-string could yield an instructive message such as

  #error redacted to avoid accidental information leak; see
documentation for current-exn-string-enabled?

plus suitable RED FONT DANGER TEXT in the documentation making it clear
to users that they should think about the contexts in which the
resulting strings will be published.

Tony

-- 
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.