Re: [racket-users] web server: database result paging

2015-04-24 Thread George Neuner

On 4/23/2015 1:45 PM, Jay McCarthy wrote:

On Thu, Apr 23, 2015 at 1:35 PM, David Vanderson
david.vander...@gmail.com wrote:

 Jay - is there any connection between a saved continuation and the thread
 that created it?

The values of the parameters are saved in the continuation and
inherited from the thread.


That's going to be a problem because there's a large amount of state - 
not simply control variables, but also an open database connection and a 
complex dynamic database query that is expensive to re-execute.  Many 
clients may be simultaneously executing separate instances of the query 
- if I can't keep the database connection open, I can't use per client 
temporary tables to cache results and will have to do something ugly 
with a permanent table.



On Thu, Apr 23, 2015 at 1:35 PM, David Vanderson
david.vander...@gmail.com wrote:

What I'd like, though, is for it to wake up again and log some exit 
data when all continuations expire.
I'm not sure I understand the motivation here.  Can you give an 
example of the kind of exit data you want to log? 


After I wrote that I had started to think maybe I don't really need the 
exit log ... but, If I can't keep the database connection open, then I 
have to know when the thread terminates so I can clean up cached query 
results that are cluttering a permanent table.  Or spawn a top level 
thread to periodically clean out expired results.


Solutions that involve permanent cache tables are not particularly nice.

George

--
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] web server: database result paging

2015-04-24 Thread George Neuner

Hi David,

On 4/23/2015 1:35 PM, David Vanderson wrote:



What I want to do is:

create a hash representing the return object
- data to return
- URL for next page function (if applicable)
- URL for prev page function (if applicable)
convert the hash to a jsexpr
send/suspend/dispatch  the jsexpr


#lang web-server/insta

(require json)

(define (response/json jsexpr)
  (response/full 200 #Okay (current-seconds) #application/json
(list)
(list # (jsexpr-bytes jsexpr

(define (start request)
  (define idx 0) ; state stored in continuation

  (define (show-prev-page request)
(set! idx (sub1 idx))
(show-page))

  (define (show-next-page request)
(set! idx (add1 idx))
(show-page))

  (define (show-page)
(send/suspend/dispatch
 (lambda (embed/url)
   ; make hash representing the return object
   (define js-hash (hasheq 'data idx
   'url-next-page (embed/url show-next-page)
   'url-prev-page (embed/url 
show-prev-page)))


   ; send the response, a hasheq is already a jsexpr
   (response/json js-hash

  (show-page))


Does this do what you want?


Possibly.  Sorry, I moved on to something else in the meantime and I 
have to get back to this.
Is it required to use define or would let bound variables in start work 
also?


George


--
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] web server: database result paging

2015-04-24 Thread Jay McCarthy
On Fri, Apr 24, 2015 at 7:32 AM, George Neuner gneun...@comcast.net wrote:
 Hi Jay,

 On 4/24/2015 7:03 AM, Jay McCarthy wrote:

 On Fri, Apr 24, 2015 at 6:31 AM, George Neuner gneun...@comcast.net
 wrote:
  On 4/23/2015 1:45 PM, Jay McCarthy wrote:
 
  The values of the parameters are saved in the continuation and
  inherited from the thread.
 
 
  That's going to be a problem because there's a large amount of state -
  not
  simply control variables, but also an open database connection and a
  complex
  dynamic database query that is expensive to re-execute.  Many clients
  may be
  simultaneously executing separate instances of the query - if I can't
  keep
  the database connection open, I can't use per client temporary tables to
  cache results and will have to do something ugly with a permanent table.
 

 I'm surprised that you use so many parameters:

 http://docs.racket-lang.org/guide/parameterize.html?q=parameter#%28tech._parameter%29


 Why?  Web applications are as complicated as native ones.

 There are 9 arguments to the initial request which are used to construct a
 complex [expensive to execute] dynamic SQL query.  This query may return
 hundreds of results so the results need to be paged to the client.  Also,
 there is exactly once accounting that must be done on results that
 actually are sent to the client [ not simply returned by the query ].

 So it's not parameterized per se  like a thread, but there is a lot of
 state that needs to be maintained to service subsequent result page
 requests: the open database connection [which maintains the query results
 until closed], several pieces of client information used for accounting, the
 current page of results, etc.

My point is that ONLY the result of make-parameter and parameterize is
saved from the thread. In Racket a parameter has nothing to do with
a function argument. I believe you are confused by the two when you
say There are 9 arguments If you follow that documentation link,
you'll see that parameter is a very specific thing in Racket and
very few programs use them at all.

Jay

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


[racket-users] Re: What is the purpose of the undocumented #:dispatch option for define-generics?

2015-04-24 Thread Alexis King
Actually, looking over this, it looks like #:dispatch just overrides the 
existing predicate rather than augmenting it in any way. This still seems 
pretty strange. What is the use case for this?

 On Apr 24, 2015, at 00:49, Alexis King lexi.lam...@gmail.com wrote:
 
 I’m working my way through the implementation of racket/generic, and this 
 jumped out at me as a little odd. Apparently, in the #:defaults and 
 #:fast-defaults clauses of define-generics, there is support for an 
 undocumented #:dispatch clause. Using it looks a like this:
 
 (define-generics fooable
  (foo fooable)
  #:defaults
  ([list? #:dispatch empty?
(define (foo fooable)
  (displayln the empty list was foo'd))]))
 
 As far I can tell, all this does is introduce an extra predicate that is 
 checked in addition to the other one. As far as I can tell, this could just 
 be done with (and/c list? empty?), so this feels quite redundant. More 
 bizarre, if the #:dispatch clause is omitted, then it defaults to the same as 
 the first predicate!
 
 This means that the predicate is, when used as documented, always applied 
 twice for no reason I can discern. Any authors of racket/generic that could 
 provide some insight on what this is and why it exists?
 
 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] web server: database result paging

2015-04-24 Thread Jay McCarthy
On Fri, Apr 24, 2015 at 6:31 AM, George Neuner gneun...@comcast.net wrote:
 On 4/23/2015 1:45 PM, Jay McCarthy wrote:

 On Thu, Apr 23, 2015 at 1:35 PM, David Vanderson
 david.vander...@gmail.com wrote:

  Jay - is there any connection between a saved continuation and the
  thread
  that created it?

 The values of the parameters are saved in the continuation and
 inherited from the thread.


 That's going to be a problem because there's a large amount of state - not
 simply control variables, but also an open database connection and a complex
 dynamic database query that is expensive to re-execute.  Many clients may be
 simultaneously executing separate instances of the query - if I can't keep
 the database connection open, I can't use per client temporary tables to
 cache results and will have to do something ugly with a permanent table.


I'm surprised that you use so many parameters:
http://docs.racket-lang.org/guide/parameterize.html?q=parameter#%28tech._parameter%29

 On Thu, Apr 23, 2015 at 1:35 PM, David Vanderson
 david.vander...@gmail.com wrote:

 What I'd like, though, is for it to wake up again and log some exit data
 when all continuations expire.

 I'm not sure I understand the motivation here.  Can you give an example of
 the kind of exit data you want to log?


 After I wrote that I had started to think maybe I don't really need the exit
 log ... but, If I can't keep the database connection open, then I have to
 know when the thread terminates so I can clean up cached query results that
 are cluttering a permanent table.  Or spawn a top level thread to
 periodically clean out expired results.

 Solutions that involve permanent cache tables are not particularly nice.

 George



-- 
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] web server: database result paging

2015-04-24 Thread George Neuner

Hi Jay,

On 4/24/2015 7:03 AM, Jay McCarthy wrote:

On Fri, Apr 24, 2015 at 6:31 AM, George Neuner gneun...@comcast.net wrote:
 On 4/23/2015 1:45 PM, Jay McCarthy wrote:

 The values of the parameters are saved in the continuation and
 inherited from the thread.


 That's going to be a problem because there's a large amount of state - not
 simply control variables, but also an open database connection and a complex
 dynamic database query that is expensive to re-execute.  Many clients may be
 simultaneously executing separate instances of the query - if I can't keep
 the database connection open, I can't use per client temporary tables to
 cache results and will have to do something ugly with a permanent table.


I'm surprised that you use so many parameters:
http://docs.racket-lang.org/guide/parameterize.html?q=parameter#%28tech._parameter%29


Why?  Web applications are as complicated as native ones.

There are 9 arguments to the initial request which are used to construct 
a complex [expensive to execute] dynamic SQL query.  This query may 
return hundreds of results so the results need to be paged to the 
client.  Also, there is exactly once accounting that must be done on 
results that actually are sent to the client [ not simply returned by 
the query ].


So it's not parameterized per se  like a thread, but there is a lot of 
state that needs to be maintained to service subsequent result page 
requests: the open database connection [which maintains the query 
results until closed], several pieces of client information used for 
accounting, the current page of results, etc.


George

--
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] infix notation embedded in Racket

2015-04-24 Thread Jens Axel Søgaard
2015-04-24 0:18 GMT+02:00 Alexander D. Knauth alexan...@knauth.org:


 What’s wrong with at-exp though?
 I personally don’t like (planet soegaard/infix) as much mostly because the
 other options have the benefit of working with DrRacket features such as
 check-syntax arrows and blue-boxes, but that’s just because DrRacket is
 awesome, not because at-exp is bad.


As it turns out, it is at-exp that are at fault.

The screen shot below show that arrows and renaming works when using the
infix packages with the syntax:
  ($ b^2-4*a*x)

Note that it works even for identifiers inside the string.

The arrows disappear when I use the at-exp syntax:  @${b^2-4*a*x}.
I am not sure why. Anyone?

The planet package took a *very* long time to install, so I intend to
upload a version to pkg.racket-lang.org.

/Jens Axel

-- 
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] infix notation embedded in Racket

2015-04-24 Thread Jos Koot
Thanks, I take note of that.
I was mislead by the examples in the infix docs of Jens Axel Søgaard.
These examples start with #lang at-exp scheme.
Sorry, my fault.
Jos

  _  

From: Alexander D. Knauth [mailto:alexan...@knauth.org] 
Sent: viernes, 24 de abril de 2015 12:59
To: Jos Koot
Cc: Jens Axel Søgaard; racket-users@googlegroups.com
Subject: Re: [racket-users] infix notation embedded in Racket



On Apr 24, 2015, at 3:40 AM, Jos Koot jos.k...@gmail.com wrote:


With respect to at-exp: I want my infix to be a simple macro that can be
required within any arbitrary #lang racket module and cooperates well with
all binding forms in that module.


Well, since at-exp can be used with not only #lang racket but others as well
(scheme, rackjure, clojure, afl, sweet-exp, basically anything that looks at
the readtable), and doesn’t interfere with or require anything about the
bindings, at-exp and (planet soegaard/infix) can be used with any arbitrary
#lang whatever module as long as #lang whatever looks at the readtable and
supports require.

-- 
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] web server: database result paging

2015-04-24 Thread George Neuner

On 4/24/2015 7:36 AM, Jay McCarthy wrote:

My point is that ONLY the result of make-parameter and parameterize is
saved from the thread. In Racket a parameter has nothing to do with
a function argument. I believe you are confused by the two when you
say There are 9 arguments If you follow that documentation link,
you'll see that parameter is a very specific thing in Racket and
very few programs use them at all.


I'm not using parameterize at all (at least not explicitly).   I receive 
a web request that has up to 9 arguments contained in its bindings.



(define (search request)
  (let* [
 (params (request-bindings request))
 (cookies(request-cookies  request))

 (pid(find-cookie pid cookies))
 (county (exists-binding? 'county params))
 (state  (exists-binding? 'state  params))
 (search-txt (exists-binding? 'query  params))
 (search-and (exists-binding? 'all  params))
 (search-or  (exists-binding? 'any  params))
 (search-not (exists-binding? 'none params))
 (page-size  (exists-binding? 'page params))
 (sort   (exists-binding? 'sort params))
 :


Using those arguments, I retrieve information from the database 
regarding the client that issued the request and construct a complex 
database query.  When that query succeeds, I need to enter additional 
accounting data for each result based on the client - but only for 
results that the client actually sees (paging), not necessarily for 
every result.


So I need to maintain a lot of state through a continuation: the open 
database connection [to cache the query results in the database], the 
current page that the client is looking at (for navigation), and ideally 
the client information for accounting [though I could look that up again 
if necessary].


George


--
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] web server: database result paging

2015-04-24 Thread Jay McCarthy
On Fri, Apr 24, 2015 at 8:13 AM, George Neuner gneun...@comcast.net wrote:
 On 4/24/2015 7:36 AM, Jay McCarthy wrote:

 My point is that ONLY the result of make-parameter and parameterize is
 saved from the thread. In Racket a parameter has nothing to do with
 a function argument. I believe you are confused by the two when you
 say There are 9 arguments If you follow that documentation link,
 you'll see that parameter is a very specific thing in Racket and
 very few programs use them at all.


 I'm not using parameterize at all (at least not explicitly).   I receive a
 web request that has up to 9 arguments contained in its bindings.

Therefore, nothing from the creating thread will be saved with the
continuation. Only the local bindings will be saved.

Jay


 (define (search request)
   (let* [
  (params (request-bindings request))
  (cookies(request-cookies  request))

  (pid(find-cookie pid cookies))
  (county (exists-binding? 'county params))
  (state  (exists-binding? 'state  params))
  (search-txt (exists-binding? 'query  params))
  (search-and (exists-binding? 'all  params))
  (search-or  (exists-binding? 'any  params))
  (search-not (exists-binding? 'none params))
  (page-size  (exists-binding? 'page params))
  (sort   (exists-binding? 'sort params))
  :


 Using those arguments, I retrieve information from the database regarding
 the client that issued the request and construct a complex database query.
 When that query succeeds, I need to enter additional accounting data for
 each result based on the client - but only for results that the client
 actually sees (paging), not necessarily for every result.

 So I need to maintain a lot of state through a continuation: the open
 database connection [to cache the query results in the database], the
 current page that the client is looking at (for navigation), and ideally the
 client information for accounting [though I could look that up again if
 necessary].

 George





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


[racket-users] Re: infix notation embedded in Racket

2015-04-24 Thread Jens Axel Søgaard
2015-04-23 18:51 GMT+02:00 Jos Koot jos.k...@gmail.com:

  Long ago I made various parsers (most of them in Fortran or assembler)
 for expressions with infix notation. I always used push-down automata with
 two or more stacks. Now I am playing with macros in Racket that allow
 infix notation embedded in Racket without explicitly using push-down
 automata. However, I encounter a contradiction in my desires as explained
 below. I have looked at 'Infix expressions for PLT Scheme' available in
 planet and made by Jens Axel Søgaard. In his approach a+b is evaluated as
 though written as (+ a b). However:

 #lang at-exp scheme
 (require (planet soegaard/infix))
 (define a+b 4)
 (define a 1) (define b 2)
 @${a+b}  ; evaluates to 3

 A Racket variable can contain characters such as +, -, * etc.
 This makes @${a+b} confusing
 (not necessarily ambiguous, though, depending on syntax and semantics.


The rule is that operators such as +,-, * behave as operators in infix
expressions.
My intention was to support identifiers with, say, - in them using bar
notation as in |foo-bar|
but I never got around to add them.

If one want to allow the usual operators in identifiers without a quoting
mechanism,
then spaces are need to separate operators and identifiers - which may or
may not
fell annoying.

/Jens Axel

-- 
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] RE: infix notation embedded in Racket

2015-04-24 Thread Jos Koot
Sorry, it was me that was not following.
After looking into your source main.ss I found out how to use macro $.
Looked into some of your other source files too.
Impressive.
Thanks, Jos

 
  _  

From: jensaxelsoega...@gmail.com [mailto:jensaxelsoega...@gmail.com] On
Behalf Of Jens Axel Søgaard
Sent: viernes, 24 de abril de 2015 18:32
To: Jos Koot
Cc: racket-users@googlegroups.com
Subject: Re: [racket-users] RE: infix notation embedded in Racket




2015-04-24 18:25 GMT+02:00 Jos Koot jos.k...@gmail.com:



Hi Jens Axel,
 
Thanks for replying and explaining.
 
Can you discriminate between a+b and |a+b| or a|+|b?


When I get around to adding |...| identifiers to the lexer, it will work
like this:

  a+b   will be parsed as (+ a b)
  |a+b|  as a+b(a single identifier)
  a|+|b  will be passed as (+ a b)


I don't see how without using a language with it's own key-binding for |.



I am not following. The $ macro can be required into any language?. 

/Jens Axel


-- 
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] web server: database result paging

2015-04-24 Thread George Neuner

On 4/24/2015 1:29 PM, David Vanderson wrote:

It sounds like you are not happy with the continuation model.


No.  I am just trying to understand how it works and to figure out 
whether I can work with it.  The documentation sometimes is not clear 
and getting enough information sometimes is like pulling teeth. :-(


WRT to your JSON URL example, it looks like it may be adaptable to my needs.

Thanks,
George

--
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] infix notation embedded in Racket

2015-04-24 Thread Alexander D. Knauth

On Apr 24, 2015, at 8:44 AM, Jens Axel Søgaard jensa...@soegaard.net wrote:

 As it turns out, it is at-exp that are at fault.
 
 The screen shot below show that arrows and renaming works when using the 
 infix packages with the syntax:
   ($ b^2-4*a*x)
 
 Note that it works even for identifiers inside the string.

Oh! Well that’s a pleasant surprise! I didn’t know that check-syntax arrows 
could point to “identifiers” within strings! 

 The arrows disappear when I use the at-exp syntax:  @${b^2-4*a*x}. 
 I am not sure why. Anyone?

I tried this and this worked with at-exp:
#lang at-exp racket
(require (for-syntax syntax/parse))
(define-syntax m
  (syntax-parser
[(m str)
 (datum-syntax #'str (string-symbol (syntax-e #'str)) #'str #'str)]))
(let ([x 5])
  @m{x})

But that made me think of doing this:

In main.ss, line 68, you use datum-syntax with three arguments, but it works 
if you add the fourth argument:
 (datum-syntax 
  #'str
  (apply string-append
 (map syntax-datum 
  (syntax-list #'(str str* ...
  (list (syntax-source #'str)
line col pos
(syntax-span #'str))
   #'str)

 The planet package took a *very* long time to install, so I intend to upload 
 a version to pkg.racket-lang.org.
 
 /Jens Axel
 infix.png

-- 
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] What is the purpose of the undocumented #:dispatch option for define-generics?

2015-04-24 Thread Vincent St-Amour
Carl introduced it in this commit:
https://github.com/plt/racket/commit/97b78ace5b3f7cebe7604513142ba488acee6903

The motivation seems to allowing dispatch to fail faster (and go on to
the next case) for defaults / fast-defaults. E.g., if you know that the
only lists that are dicts are alists, then when trying that case during
dispatch, you can first check `list?`. If that fails, you can move on
right away to the next case, without having to do the more expensive
`alist?` check. If it succeeds, then you proceed to the full `alist?`
check, and either call the right method or error.

IIUC, this feature does not seem necessary. It should always be possible
to encode this pattern using a single predicate, e.g., by using
`(conjoin list? alist?)`, which will fail just as fast. Unless I'm
missing something, that should be equivalent.

Carl: Is my understanding correct?

If that's the case, and because it's undocumented, I'd be inclined to
remove it from the public `define-generics` interface.

Vincent


At Fri, 24 Apr 2015 00:49:19 -0700,
Alexis King wrote:
 
 I’m working my way through the implementation of racket/generic, and this 
 jumped out at me as a little odd. Apparently, in the #:defaults and 
 #:fast-defaults clauses of define-generics, there is support for an 
 undocumented #:dispatch clause. Using it looks a like this:
 
 (define-generics fooable
   (foo fooable)
   #:defaults
   ([list? #:dispatch empty?
 (define (foo fooable)
   (displayln the empty list was foo'd))]))
 
 As far I can tell, all this does is introduce an extra predicate that is 
 checked in addition to the other one. As far as I can tell, this could just 
 be done with (and/c list? empty?), so this feels quite redundant. More 
 bizarre, if the #:dispatch clause is omitted, then it defaults to the same as 
 the first predicate!
 
 This means that the predicate is, when used as documented, always applied 
 twice for no reason I can discern. Any authors of racket/generic that could 
 provide some insight on what this is and why it exists?
 
 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.

-- 
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 internal error

2015-04-24 Thread Robby Findler
Are you sure you have the latest version of the code? That line number
isn't a function in my version.

Robby

On Fri, Apr 24, 2015 at 6:40 PM, Alexander D. Knauth
alexan...@knauth.org wrote:
 Restarting didn’t help, and running raco setup and then restarting didn’t 
 help either.

 On Apr 24, 2015, at 7:34 PM, Alexander D. Knauth alexan...@knauth.org wrote:

 I’m getting similar internal errors again:
 hash-ref: contract violation
  expected: hash?
  given: #f
  argument position: 1st
  other arguments...:
   '|let |
   '()
  context...:
   /Applications/Racket/April-16/Racket 
 v6.2.0.2/share/pkgs/drracket/drracket/private/syncheck/blueboxes-gui.rkt:450:4:
  compute-tag+rng method in ...ck/blueboxes-gui.rkt:175:2
   /Applications/Racket/April-16/Racket 
 v6.2.0.2/share/pkgs/gui-lib/framework/private/coroutine.rkt:47:20
   /Applications/Racket/April-16/Racket 
 v6.2.0.2/share/pkgs/gui-lib/framework/private/coroutine.rkt:56:0: 
 coroutine-run
   /Applications/Racket/April-16/Racket 
 v6.2.0.2/collects/racket/contract/private/arrow-val-first.rkt:265:18
   /Applications/Racket/April-16/Racket 
 v6.2.0.2/share/pkgs/drracket/drracket/private/syncheck/blueboxes-gui.rkt:414:4:
  update-the-strs method in ...ck/blueboxes-gui.rkt:175:2
   /Applications/Racket/April-16/Racket 
 v6.2.0.2/share/pkgs/gui-lib/framework/private/logging-timer.rkt:41:0: 
 log-timeline/proc
   /Applications/Racket/April-16/Racket 
 v6.2.0.2/share/pkgs/gui-lib/mred/private/wx/common/timer.rkt:34:38
   /Applications/Racket/April-16/Racket 
 v6.2.0.2/share/pkgs/gui-lib/mred/private/wx/common/queue.rkt:454:6
   /Applications/Racket/April-16/Racket 
 v6.2.0.2/share/pkgs/gui-lib/mred/private/wx/common/queue.rkt:505:32
   /Applications/Racket/April-16/Racket 
 v6.2.0.2/share/pkgs/gui-lib/mred/private/wx/common/queue.rkt:653:3

 I’m not sure if this could be relevant, but these first started showing up 
 when I was trying to do stuff like this, but they have continued after that:
 #lang at-exp racket
 (begin-for-syntax
  (define stx #'@{hello})
  (define hello-stx (car (syntax-e stx)))
  (define (orig stx) (syntax-property stx 'original-for-check-syntax #t)))
 (define-syntax (m _)
  (with-syntax ([x1 (syntax/loc hello-stx x)]
[x2 (syntax/loc #'here x)])
#'(let ([x1 #f])
x2)))
 (m)

 I’ll try restarting and running raco setup again, and see if that fixes it.


 On Apr 22, 2015, at 10:16 PM, Robby Findler ro...@eecs.northwestern.edu 
 wrote:

 I'm glad to hear that helped.

 Looking at the code, I'm puzzled because I don't see how
 configure-runtime can show up in the code that is in that stacktrace.
 I'd expect configure-runtime to show up in code that was initializing
 an environment for running a language, but that code is the new
 blueboxes code. It's possible it is using a function that is somehow
 doing that, I guess? It calls path-module-path and
 xref-binding-definition-tag (that does some stuff with module paths).
 I'm stumped.

 Robby


 On Wed, Apr 22, 2015 at 8:36 PM, Alexander D. Knauth
 alexan...@knauth.org wrote:
 Restarting didn’t help, but then raco setup hanged because of an infinite 
 loop in a package of mine, which I then fixed, and then I tried raco setup 
 again, and then it was working again.  So the problem, for me, right now, 
 is fixed.

 On Apr 22, 2015, at 9:23 PM, Robby Findler ro...@eecs.northwestern.edu 
 wrote:

 Does restarting help? How about re-running 'raco setup'?

 Robby

 On Wed, Apr 22, 2015 at 6:21 PM, Alexander D. Knauth
 alexan...@knauth.org wrote:
 I’m not sure how it got into this state, but now every time I start 
 typing something or anything like that I get a DrRacket internal error 
 window saying:
 hash-ref: contract violation
 expected: hash?
 given: #f
 argument position: 1st
 other arguments...:
 'configure-runtime
 '()
 context...:
 /Applications/Racket/April-16/Racket 
 v6.2.0.2/share/pkgs/drracket/drracket/private/syncheck/blueboxes-gui.rkt:450:4:
  compute-tag+rng method in ...ck/blueboxes-gui.rkt:175:2
 /Applications/Racket/April-16/Racket 
 v6.2.0.2/share/pkgs/gui-lib/framework/private/coroutine.rkt:47:20
 /Applications/Racket/April-16/Racket 
 v6.2.0.2/share/pkgs/gui-lib/framework/private/coroutine.rkt:56:0: 
 coroutine-run
 /Applications/Racket/April-16/Racket 
 v6.2.0.2/collects/racket/contract/private/arrow-val-first.rkt:265:18
 /Applications/Racket/April-16/Racket 
 v6.2.0.2/share/pkgs/drracket/drracket/private/syncheck/blueboxes-gui.rkt:414:4:
  update-the-strs method in ...ck/blueboxes-gui.rkt:175:2
 /Applications/Racket/April-16/Racket 
 v6.2.0.2/share/pkgs/gui-lib/framework/private/logging-timer.rkt:41:0: 
 log-timeline/proc
 /Applications/Racket/April-16/Racket 
 v6.2.0.2/share/pkgs/gui-lib/mred/private/wx/common/timer.rkt:34:38
 /Applications/Racket/April-16/Racket 
 v6.2.0.2/share/pkgs/gui-lib/mred/private/wx/common/queue.rkt:454:6
 /Applications/Racket/April-16/Racket 
 v6.2.0.2/share/pkgs/gui-lib/mred/private/wx/common/queue.rkt:505:32
 

Re: [racket-users] RE: infix notation embedded in Racket

2015-04-24 Thread Jens Axel Søgaard
2015-04-24 18:25 GMT+02:00 Jos Koot jos.k...@gmail.com:

  Hi Jens Axel,

 Thanks for replying and explaining.

 Can you discriminate between a+b and |a+b| or a|+|b?

 When I get around to adding |...| identifiers to the lexer, it will work
like this:

  a+b   will be parsed as (+ a b)
  |a+b|  as a+b(a single identifier)
  a|+|b  will be passed as (+ a b)

I don't see how without using a language with it's own key-binding for |.


I am not following. The $ macro can be required into any language?.

/Jens Axel

-- 
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] RE: infix notation embedded in Racket

2015-04-24 Thread Jos Koot
Hi Jens Axel,
 
Thanks for replying and explaining.
 
Can you discriminate between a+b and |a+b| or a|+|b?
I don't see how without using a language with it's own key-binding for |.
 
I prefer my infix to be usable without forcing the user to go into a
specific language. For the moment I use spaces. As ugly that I probably are
not going to use my own infix :) Allowing spaces to be omitted restricts the
names of variables too much deviating from Racket, imho. As I wrote before,
I am just playing with a parser without explicit use of a push down
automaton. So far my experience is that this is very well possible, in fact
much easier.
 
Thanks again, Jos
 

 
  _  

From: jensaxelsoega...@gmail.com [mailto:jensaxelsoega...@gmail.com] On
Behalf Of Jens Axel Søgaard
Sent: viernes, 24 de abril de 2015 14:50
To: Jos Koot
Cc: racket-users@googlegroups.com
Subject: Re: infix notation embedded in Racket


2015-04-23 18:51 GMT+02:00 Jos Koot jos.k...@gmail.com:



Long ago I made various parsers (most of them in Fortran or assembler) for
expressions with infix notation. I always used push-down automata with two
or more stacks. Now I am playing with macros in Racket that allow infix
notation embedded in Racket without explicitly using push-down automata.
However, I encounter a contradiction in my desires as explained below. I
have looked at 'Infix expressions for PLT Scheme' available in planet and
made by Jens Axel Søgaard. In his approach a+b is evaluated as though
written as (+ a b). However:
 
#lang at-exp scheme
(require (planet soegaard/infix))
(define a+b 4)
(define a 1) (define b 2)
@${a+b}  ; evaluates to 3
 
A Racket variable can contain characters such as +, -, * etc.
This makes @${a+b} confusing
(not necessarily ambiguous, though, depending on syntax and semantics.



The rule is that operators such as +,-, * behave as operators in infix
expressions.
My intention was to support identifiers with, say, - in them using bar
notation as in |foo-bar|
but I never got around to add them.

If one want to allow the usual operators in identifiers without a quoting
mechanism,
then spaces are need to separate operators and identifiers - which may or
may not
fell annoying.

/Jens Axel

-- 
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] web server: database result paging

2015-04-24 Thread David Vanderson

On 04/24/2015 06:39 AM, George Neuner wrote:


Possibly.  Sorry, I moved on to something else in the meantime and I 
have to get back to this.
Is it required to use define or would let bound variables in start 
work also?


George



Yes - let bound variables would work the same.

Thanks,
Dave

--
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] web server: database result paging

2015-04-24 Thread David Vanderson



On 04/24/2015 08:13 AM, George Neuner wrote:
I'm not using parameterize at all (at least not explicitly).   I 
receive a web request that has up to 9 arguments contained in its 
bindings.



(define (search request)
  (let* [
 (params (request-bindings request))
 (cookies(request-cookies  request))

 (pid(find-cookie pid cookies))
 (county (exists-binding? 'county params))
 (state  (exists-binding? 'state  params))
 (search-txt (exists-binding? 'query  params))
 (search-and (exists-binding? 'all  params))
 (search-or  (exists-binding? 'any  params))
 (search-not (exists-binding? 'none params))
 (page-size  (exists-binding? 'page params))
 (sort   (exists-binding? 'sort params))
 :


Using those arguments, I retrieve information from the database 
regarding the client that issued the request and construct a complex 
database query.  When that query succeeds, I need to enter additional 
accounting data for each result based on the client - but only for 
results that the client actually sees (paging), not necessarily for 
every result.


So I need to maintain a lot of state through a continuation: the open 
database connection [to cache the query results in the database], the 
current page that the client is looking at (for navigation), and 
ideally the client information for accounting [though I could look 
that up again if necessary].


George

My intuition is the more state you have, the better the continuation 
model serves you, as you don't have to pass and manage all that state 
explicitly through cookies, url params, etc.  It sounds like you are not 
happy with the continuation model.  You can of course use the regular 
web patterns in a racket web service, but you'll still have many of the 
same issues.  Even in a non-continuation based service, you'll need some 
way of maintaining a client-database connection mapping, and find some 
way of removing stale db connections once the client is gone, which 
you can never know for sure.


Are you trying to decide between using continuations and regular web 
state patterns?


Thanks,
Dave

--
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] What is the purpose of the undocumented #:dispatch option for define-generics?

2015-04-24 Thread Alexis King
I’m working my way through the implementation of racket/generic, and this 
jumped out at me as a little odd. Apparently, in the #:defaults and 
#:fast-defaults clauses of define-generics, there is support for an 
undocumented #:dispatch clause. Using it looks a like this:

(define-generics fooable
  (foo fooable)
  #:defaults
  ([list? #:dispatch empty?
(define (foo fooable)
  (displayln the empty list was foo'd))]))

As far I can tell, all this does is introduce an extra predicate that is 
checked in addition to the other one. As far as I can tell, this could just be 
done with (and/c list? empty?), so this feels quite redundant. More bizarre, if 
the #:dispatch clause is omitted, then it defaults to the same as the first 
predicate!

This means that the predicate is, when used as documented, always applied twice 
for no reason I can discern. Any authors of racket/generic that could provide 
some insight on what this is and why it exists?

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.


[racket-users] define-language, trouble with parentheses.

2015-04-24 Thread Jos Koot
I have trouble translating the following into a define-language form:
 
term ::= number
term ::= number + term
 
An attempt like:
 
(define-language my-language
 (term number (number + term))
 
does not work. It accepts (1 + (2 + 3)) and ((1 + 2) +3) but not (1 + 2 +
3).
 
May be there already is a method to do something like:
 
(define-language my-language
 (term number (number + ,@term-list))
 (term-list (term)))
 
or
 
(define-languafe my-language
 (term (number + number ... ...)))
 
where the first ... refers to + and the second one to number, alternating of
course.
 
If something like the above two above already is possible in some way,
please direct me to the related parts of the docs.
If not, would it be a great efffort to allow ,@ or ... ... in a
language-definition-clause?
If not too big an effort may be I could try to implement it, but I warn you,
I would need much guidance.
 
Thanks, Jos

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