Re: [racket-users] Intro and projects inquiry

2017-10-12 Thread Thomas Lynch
Apparently Whalesong is such an alterntiave.
https://github.com/jashkenas/coffeescript/wiki/list-of-languages-that-compile-to-js
A Lisp dialect, Clojure, has caused a lot of young folks to ask
questions/to think about Lisp (
https://m.oursky.com/why-i-chose-clojure-over-javascript-24f045daab7e).

On Thu, Oct 12, 2017 at 4:31 PM, David Storrs 
wrote:

> My suggestion would be that the single largest thing that would make
> Racket take off is if it could become a replacement for Javascript.
> The browser is the default GUI for most work these days, and doing
> real-time interfaces in the browser requires Javascript.  If Racket
> could run inside the browser and was more convenient to work with than
> Javascript then it would start climbing the hockey stick.  That would
> be an enormous project and I don't even know how you would get the
> popular browsers to adopt it; forking the browsers won't work and nor
> will making a plugin / addon -- it's got to run out of the box so that
> developers can rely on the fact that visitors to their site will be
> able to use it.
>
> For now, something that made it trivial to compile Racket to
> Javascript is probably the best option.  As it happens, I believe
> there is some effort in that direction. :>
>
> On Wed, Oct 11, 2017 at 10:37 PM, Neil Van Dyke 
> wrote:
> > Eric Griffis wrote on 10/11/2017 07:44 PM:
> >>
> >> On Wed, Oct 11, 2017 at 2:58 PM Neil Van Dyke  >> > wrote:
> >>
> >>
> >> * Being there soon with a Web Assembly and HTML5 plus server
> >> full-stack
> >> story, in case developers respond favorably to that.
> >>
> >>
> >> Web back-ends are my wheelhouse. It sure would make my professional life
> >> easier... Not gonna lie, this isn't something I'd look forward to
> banging
> >> out alone.
> >
> >
> > There are some scalable HTTP protocol handling things I'd like to try,
> > including some hardcore systems-ish programming, and then multiple
> parties
> > (including me) could layer independent framework-y things over that
> > (server-side-only, and client-side-too).
> >
> > The WebAssembly part is what might be an emerging opportunity, but am
> > guessing the best way involves working with the tentative new Chez
> backend
> > for Racket.  (Also, WebAssembly didn't look very simple nor yet as
> > well-documented as you'd want, and looks still being hammered out.  So,
> > knowing how adopted Web standards tend to happen... you might have to
> put in
> > considerable effort to catch up with and track it, buy a gorilla suit,
> munch
> > some beetle grubs[1], and hopefully become accepted by the pack, to be
> > confident that Racket will be a first-class citizen in WebAssembly.)
> >
> >> * Push DSL-based programming, for which Racket might already have
> the
> >> best technology.  (The other day, I saw someone looking to hire
> >> developers to use some DSL-based speculative methodology thing...
> >> in Ruby.)
> >>
> >>
> >> This might also be interesting. Any concrete demand out there to drive
> the
> >> process?
> >
> >
> > Chattering about DSLs now seems mainstream.  Also, Agile-esque upstart
> > methodologists are always clamoring to invent and brand approaches, now
> > including applications of DSLs. :)
> >
> > (DSLs can be little mini-languages used by programmers as part of any
> kind
> > of programming, they can be used by programmers mix traditional language
> > paradigms in a code base, they can be used to support domain
> > experts/specialists capturing and maintaining knowledge/behavior separate
> > from programmers.)
> >
> >>
> >> The Godot game engine is kinda like this, but for Python. It has a lot
> of
> >> rough edges, which could help design a good Racket alternative. There
> may be
> >> a ton of reusable functionality in a project like that.
> >
> >
> > Over a decade ago, someone was actually doing game engine-ish stuff using
> > PLT Scheme (earlier version of Racket), to, IIRC, develop a 3D training
> > simulator for first-responders in emergency scenarios.  It might've used
> the
> > open-sourced Quake engine, or just built atop OpenGL; I forget whether I
> > heard.  At the time, I guess a Lisp was a big enough win for that, and
> there
> > were a lot fewer and more primitive 3D game engines, that it made sense.
> > Today, whenever there is again a win to using Racket, I'd probably end up
> > taking an off-the-shelf (preferably libre-licensed) 3D game engine that
> met
> > all the other requirements, and make it work well with Racket.
> >
> > [1] Gary Larson, The Far Side, "So you're a *real* gorilla, are you?
> ...".
> > https://i.pinimg.com/736x/da/ed/ed/daeded47decfd2a200aca58b00a9d0e5.jpg
> >
> >
> > --
> > 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.g

Re: [racket-users] A couple of questions about Neil's html reader/writer

2015-07-29 Thread Thomas Lynch
On Thu, Jul 30, 2015 at 11:09 AM, Thomas Lynch <
thomas.ly...@reasoningtechnology.com> wrote:

> Great!  thanks Neil!
>

Ah spoke too soon! Those links just point back into this very same thread!

The most obvious difference between racket's xexpr and yours is the '@' as
the head of the attributes list.  Any idea where else I will see
divergences?


>
> On Thu, Jul 30, 2015 at 11:02 AM, Neil Van Dyke 
> wrote:
>
>> Thomas Lynch wrote on 07/29/2015 10:25 PM:
>>
>>> Neil can you comment on what other differences I might expect to find?
>>>
>>
>> Are the below 2 messages to the list helpful?
>>
>> * Historical background on SXML and Racket xexpr:
>> https://groups.google.com/d/msg/racket-users/yaOtPkd_qvs/8ruIg-Smr7cJ
>>
>> * Technical notes on implementing conversion kludge functions between
>> SXML and Racket xexpr:
>> https://groups.google.com/d/msg/racket-users/yaOtPkd_qvs/vhvAi90_CgAJ
>>
>> The historical one should also clarify why not to say "neil-xexpr" in
>> identifiers.  (I'll have to earn some better claim to fame.)
>>
>> Good luck.  I and many others have been using SXML tools happily for over
>> a decade, and at this point I'm sure we all wish the xexpr people best of
>> luck with whatever their problem is. :)
>>
>> Neil V.
>>
>>
>

-- 
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] A couple of questions about Neil's html reader/writer

2015-07-29 Thread Thomas Lynch
Great!  thanks Neil!

On Thu, Jul 30, 2015 at 11:02 AM, Neil Van Dyke 
wrote:

> Thomas Lynch wrote on 07/29/2015 10:25 PM:
>
>> Neil can you comment on what other differences I might expect to find?
>>
>
> Are the below 2 messages to the list helpful?
>
> * Historical background on SXML and Racket xexpr:
> https://groups.google.com/d/msg/racket-users/yaOtPkd_qvs/8ruIg-Smr7cJ
>
> * Technical notes on implementing conversion kludge functions between SXML
> and Racket xexpr:
> https://groups.google.com/d/msg/racket-users/yaOtPkd_qvs/vhvAi90_CgAJ
>
> The historical one should also clarify why not to say "neil-xexpr" in
> identifiers.  (I'll have to earn some better claim to fame.)
>
> Good luck.  I and many others have been using SXML tools happily for over
> a decade, and at this point I'm sure we all wish the xexpr people best of
> luck with whatever their problem is. :)
>
> Neil V.
>
>

-- 
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] A couple of questions about Neil's html reader/writer

2015-07-29 Thread Thomas Lynch
Alexander,  you will notice I pulled a couple lambdas to the top, and added
a test routine at the bottom take those out ... then the code you sent
isn't shorter.  I am also expecting to have to add more code to the
intermediate points.  I like seeing those named.  I think it is easy to
read. ... What advantage do you see in using match?

So I have been thinking about this, have come to this conclusion, what do
you think: In general grammar driven parsing is elegant against well formed
input data.  However a complication enters because the error grammar
explodes in size in comparison.  Where as if one builds a match with
cascading let (naming the parts) and cond (doing the match), all end
conditions are exposed and can be handled.  As an example, I will have to
check the tag to see if it aliases against tags the parser is using, so
that people can't send in poison xml statement.   The alternative would be
to first run the xml through a well formed checker, but that would just
move the complication to the checker, just so the parse can look pretty.

In addition, I'm concerned about the stream behavior of racket's match -
something I've promised to work on.  Notice, what happens if you try to
match pattern delineated by paren literals within nested parens, because it
does a greedy match, and it will wait for the end of stream to complete
that match using the outside most right paren.  So I don't understand match
behavior enough yet to be completely comfortable with it yet.  Independent,
in this case I suspect I like the cascading cond/let match.

Be glad to hear your thoughts on this.  Be glad to learn more about match.

On Wed, Jul 29, 2015 at 10:56 PM, Alexander D. Knauth 
wrote:

> Would it be easier using match?
>
> (define (xexpr->tok-tree an-xexpr)
>   (match as-xexpr
> ['()
>  '()]
> [(not (cons _ _))
>  (tok-make ...)]
> [(list tag)
>  (list tag)]
> [(list-rest tag (? is-at-list at-list) r2)
>  ]
> ))
>
> On Jul 29, 2015, at 7:56 AM, Thomas Lynch <
> thomas.ly...@reasoningtechnology.com> wrote:
>
> I wrote primitive conversion routines to bring the xexpr or Neil's xexpr
> into ... oh gosh, my parser token format, which by coincidence is very
> close.  Just playing with this now .. In my target format token children
> are always other tokens.  All values given as attributes in value tokens.
> I use an empty list if there are no attributes.  The conversion routines
> are very simple, though I'm just playing with this, there will be other
> cases I missed, I suspect:
>
>  (define (xexpr->tok-tree an-xexpr)
> (define (is-at-list e)
>   (and
> (pair? e)
> (pair? (car e
> (cond
>   [(null? an-xexpr) an-xexpr]
>   [(not (pair? an-xexpr)) (tok-make 'tok:value `((value ,an-xexpr)))]
> ; actually diff toks for diff types
>   [else
> (let(
>   [tag (car an-xexpr)]
>   [r1  (cdr an-xexpr)]
>   )
>   (cond
> [(null? r1) an-xexpr]
> [else
>   (let(
> [first-element (car r1)]
> [r2 (cdr r1)]
> )
> (cond
>   [(is-at-list first-element) (cons tag (cons
> first-element (map xexpr->tok-tree r2)))]
>   [else (cons tag (cons '() (map xexpr->tok-tree r1)))]
>   ))]))]))
>
> (define (test-xexpr-tok-tree-0)
>   (equal?
> (xexpr->tok-tree
>   '(html (head (title "My Title"))
>  (body ((bgcolor "white"))
>(h1 "My Heading")
>(p ((style "default")) "This is a paragraph.")
>(p "This is another paragraph."
> '(html
>()
>(head () (title () (tok:value ((value "My Title")
>(body
>  ((bgcolor "white"))
>  (h1 () (tok:value ((value "My Heading"
>  (p ((style "default")) (tok:value ((value "This is a
> paragraph."
>  (p () (tok:value ((value "This is another paragraph.")
>)))
>
>
>
> On Wed, Jul 29, 2015 at 7:05 AM, Matthew Butterick  wrote:
>
>> Yes, more or less. In an X-expression, an attribute list is the only
>> element that's a list made of sublists. A list of embedded X-expressions,
>> OTOH, will start with a symbol. To look at it another way,
>>
>> (cons symbol (list xexpr ...))
>>
>>
>> really amounts to
>>
>> (list symbol xexpr ...)
>>
>>
>> which is just
>>
>> (list symb

Re: [racket-users] A couple of questions about Neil's html reader/writer

2015-07-29 Thread Thomas Lynch
.. the conversion for neil's xexpr  .. at this point the two converters can
be abstracted by passing in two lambdas, is-at-list predicate, and
extract-at-list.   Neil can you comment on what other differences I might
expect to find?

  (define (neil-xexpr->tok-tree an-xexpr)
(define (is-at-list e)
  (and
(pair? e)
(eqv? '@ (car e
(define (extract-at-list e)
  (cdr e)
  )
(cond
  [(null? an-xexpr) an-xexpr]
  [(not (pair? an-xexpr)) (tok-make 'tok:value `((value ,an-xexpr)))]
  [else
(let(
  [tag (car an-xexpr)]
  [r1  (cdr an-xexpr)]
  )
  (cond
[(null? r1) an-xexpr]
[else
  (let(
[first-element (car r1)]
[r2 (cdr r1)]
)
(cond
  [(is-at-list first-element) (cons tag (cons
(extract-at-list first-element) (map neil-xexpr->tok-tree r2)))]
  [else (cons tag (cons '() (map neil-xexpr->tok-tree r1)))]
  ))]))]))

(define (test-neil-xexpr-tok-tree-0)
  (equal?
(neil-xexpr->tok-tree
  '(html (head (title "My Title"))
   (body (@ (bgcolor "white"))
 (h1 "My Heading")
 (p (@ (style "default")) "This is a paragraph.")
 (p "This is another paragraph."
'(html
   ()
   (head () (title () (tok:value ((value "My Title")
   (body
 ((bgcolor "white"))
 (h1 () (tok:value ((value "My Heading"
 (p ((style "default")) (tok:value ((value "This is a
paragraph."
 (p () (tok:value ((value "This is another paragraph.")
   )))

An example:

(define (test-neil-xexpr-tok-tree-0)
  (equal?
(neil-xexpr->tok-tree
  '(html (head (title "My Title"))
   (body (@ (bgcolor "white"))
 (h1 "My Heading")
 (p (@ (style "default")) "This is a paragraph.")
 (p "This is another paragraph."
'(html
   ()
   (head () (title () (tok:value ((value "My Title")
   (body
 ((bgcolor "white"))
 (h1 () (tok:value ((value "My Heading"
 (p ((style "default")) (tok:value ((value "This is a
paragraph."
 (p () (tok:value ((value "This is another paragraph.")
   )))


On Wed, Jul 29, 2015 at 7:56 PM, Thomas Lynch <
thomas.ly...@reasoningtechnology.com> wrote:

> I wrote primitive conversion routines to bring the xexpr or Neil's xexpr
> into ... oh gosh, my parser token format, which by coincidence is very
> close.  Just playing with this now .. In my target format token children
> are always other tokens.  All values given as attributes in value tokens.
> I use an empty list if there are no attributes.  The conversion routines
> are very simple, though I'm just playing with this, there will be other
> cases I missed, I suspect:
>
>  (define (xexpr->tok-tree an-xexpr)
> (define (is-at-list e)
>   (and
> (pair? e)
> (pair? (car e
> (cond
>   [(null? an-xexpr) an-xexpr]
>   [(not (pair? an-xexpr)) (tok-make 'tok:value `((value ,an-xexpr)))]
> ; actually diff toks for diff types
>   [else
> (let(
>   [tag (car an-xexpr)]
>   [r1  (cdr an-xexpr)]
>   )
>   (cond
> [(null? r1) an-xexpr]
> [else
>   (let(
> [first-element (car r1)]
> [r2 (cdr r1)]
> )
> (cond
>   [(is-at-list first-element) (cons tag (cons
> first-element (map xexpr->tok-tree r2)))]
>   [else (cons tag (cons '() (map xexpr->tok-tree r1)))]
>   ))]))]))
>
> (define (test-xexpr-tok-tree-0)
>   (equal?
> (xexpr->tok-tree
>   '(html (head (title "My Title"))
>  (body ((bgcolor "white"))
>(h1 "My Heading")
>(p ((style "default")) "This is a paragraph.")
>(p "This is another paragraph."
> '(html
>()
>(head () (title () (tok:value ((value "My Title")
>(body
>  ((bgcolor "white"))
>  (h1 () (tok:value ((value "My Heading"
>  (p ((style "default")) (tok:value ((value "This is a
> paragraph."

Re: [racket-users] A couple of questions about Neil's html reader/writer

2015-07-29 Thread Thomas Lynch
I wrote primitive conversion routines to bring the xexpr or Neil's xexpr
into ... oh gosh, my parser token format, which by coincidence is very
close.  Just playing with this now .. In my target format token children
are always other tokens.  All values given as attributes in value tokens.
I use an empty list if there are no attributes.  The conversion routines
are very simple, though I'm just playing with this, there will be other
cases I missed, I suspect:

 (define (xexpr->tok-tree an-xexpr)
(define (is-at-list e)
  (and
(pair? e)
(pair? (car e
(cond
  [(null? an-xexpr) an-xexpr]
  [(not (pair? an-xexpr)) (tok-make 'tok:value `((value ,an-xexpr)))] ;
actually diff toks for diff types
  [else
(let(
  [tag (car an-xexpr)]
  [r1  (cdr an-xexpr)]
  )
  (cond
[(null? r1) an-xexpr]
[else
  (let(
[first-element (car r1)]
[r2 (cdr r1)]
)
(cond
  [(is-at-list first-element) (cons tag (cons first-element
(map xexpr->tok-tree r2)))]
  [else (cons tag (cons '() (map xexpr->tok-tree r1)))]
  ))]))]))

(define (test-xexpr-tok-tree-0)
  (equal?
(xexpr->tok-tree
  '(html (head (title "My Title"))
 (body ((bgcolor "white"))
   (h1 "My Heading")
   (p ((style "default")) "This is a paragraph.")
   (p "This is another paragraph."
'(html
   ()
   (head () (title () (tok:value ((value "My Title")
   (body
 ((bgcolor "white"))
 (h1 () (tok:value ((value "My Heading"
 (p ((style "default")) (tok:value ((value "This is a
paragraph."
 (p () (tok:value ((value "This is another paragraph.")
   )))



On Wed, Jul 29, 2015 at 7:05 AM, Matthew Butterick  wrote:

> Yes, more or less. In an X-expression, an attribute list is the only
> element that's a list made of sublists. A list of embedded X-expressions,
> OTOH, will start with a symbol. To look at it another way,
>
> (cons symbol (list xexpr ...))
>
>
> really amounts to
>
> (list symbol xexpr ...)
>
>
> which is just
>
> (list symbol (list (list symbol string) ...) xexpr ...)
>
>
> but without the attribute list, cf.
>
> '(p "foo" "bar")
>
> '(p ((style "default")) "foo" "bar")
>
> A recurring annoyance in X-expressions is distinguishing these two cases
> on input, because the second element can be either an attribute list or
> nested X-expression. You can use `xexpr-drop-empty-attributes` to force an
> attribute list (even empty). My `txexpr` package also has utilities for
> handling them.
>
>
> Here is the syntax for an xexp from xexp? in the reference:
>
>   xexpr = string  | (list
> 
>  symbol (list
> 
>  (list
> 
>  symbol string) ...) xexpr ...)  | (cons
> 
>  symbol (list
> 
>  xexpr ...))  | symbol  | valid-char?
> 
>   | cdata  | misc
> And in this latter syntax, how is the attribute list distinguished from a
> list of embedded xexps? Is it due to the nesting in the attribute 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.


[racket-users] A couple of questions about Neil's html reader/writer

2015-07-28 Thread Thomas Lynch
Is Neil's xexp format different that the one being used in racket due to
the
attribute list beginning with an '@'?

(write-html '((html (head (title "My Title")) (body (@ (bgcolor
"white"))   (h1 "My Heading")   (p "This is a
paragraph.")   (p "This is another paragraph." (
current-output-port))

Here is an example xexp from some guys homework assignment (
http://web.cs.wpi.edu/~cs1102/a12/Assignments/Hwk7/html.html)

(form ((action "http://localhost:8088/hello";))
  "What is your first name?"
  (input ((type "text") (name "firstName")))
  (input ((type "submit") (value "Click Here"

Here is the syntax for an xexp from xexp? in the reference:

  xexpr = string  | (list

 symbol (list

 (list

 symbol string) ...) xexpr ...)  | (cons

 symbol (list

 xexpr ...))  | symbol  | valid-char?

  | cdata  | misc
And in this latter syntax, how is the attribute list distinguished from a
list of embedded xexps? Is it due to the nesting in the attribute list?

Another question, the racket manuals show xexp->string being used to
generate html.  Neil has a separate write-html function.  Why the
divergence?

Thanks in advance!

-- 
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] how to get line numbers on syntax errors on load?

2015-03-10 Thread Thomas Lynch
Greg, the code fails to load due to the error, so trace doesn't get a
chance to participate.

On Wed, Mar 11, 2015 at 5:19 AM, Greg Hendershott  wrote:

> >> Is there a way to coerce racket to be more specific in its messages?
>
> Although I don't know if it would do better with this particular error,
> generally errortrace gives much better stack traces:
>
>   http://docs.racket-lang.org/errortrace/quick-instructions.html
>
> It does so by instrumenting the code. Which means it will run more
> slowly. Which I imagine is why it's not enabled by default.
>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] how to get line numbers on syntax errors on load?

2015-03-09 Thread Thomas Lynch
It is scary to run regression on over ten thousand lines of code and then
racket spits out error messages but does not give source file location
information, as above.   So if anyone has an answer for this I would like
to hear it.

FYI,  in this particular case,  test-hook was defined lower in the
basic-lib.rkt than its first invocation - though at top level of the
module.  Not sure why this scenario fails here, now, but the test-hook
definition was easily moved up.  The error messaged mentioned test-hook,
but that was practically meaningless as every regression routine has one.
... It had nothing to do with macros or unicode as first thought.



On Tue, Mar 10, 2015 at 12:44 PM, Thomas Lynch <
thomas.ly...@reasoningtechnology.com> wrote:

> When loading modules I sometimes get syntax errors - rightfully so.
> However, the errors sometimes don't have line numbers, making them time
> consuming to find.
>
> Here is one today:
>
> Welcome to Racket v5.2.1.
> racket@> (enter! "ap.rkt")
> link: reference (phase 0) to a variable in module "basic-lib.rkt" that is
> uninitialized (phase level 0); reference appears in module: "realtime.rkt"
> in: test-hook
>
>
>
> Which variable?  Which line in which file?
>
> This is old code that is not playing well within a new environment. There
> are thousands of combinations possible against this information.   .. I
> suspect this has to do with using unicode characters, specifically lambda,
> within macros, if so it will not be long to find it.  However, in the worse
> case I will have to start a binary search cutting out blocks of code, and
> inserting stub routines .. but this is time consuming, and this sort of
> vague message is not a one time occurrence.
>
> Is there a way to coerce racket to be more specific in its messages?
>
>

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] how to get line numbers on syntax errors on load?

2015-03-09 Thread Thomas Lynch
When loading modules I sometimes get syntax errors - rightfully so.
However, the errors sometimes don't have line numbers, making them time
consuming to find.

Here is one today:

Welcome to Racket v5.2.1.
racket@> (enter! "ap.rkt")
link: reference (phase 0) to a variable in module "basic-lib.rkt" that is
uninitialized (phase level 0); reference appears in module: "realtime.rkt"
in: test-hook



Which variable?  Which line in which file?

This is old code that is not playing well within a new environment. There
are thousands of combinations possible against this information.   .. I
suspect this has to do with using unicode characters, specifically lambda,
within macros, if so it will not be long to find it.  However, in the worse
case I will have to start a binary search cutting out blocks of code, and
inserting stub routines .. but this is time consuming, and this sort of
vague message is not a one time occurrence.

Is there a way to coerce racket to be more specific in its messages?

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] CFP: Workshop on Generic Programming 2015 - Deadline May 15

2015-03-05 Thread Thomas Lynch
gulp, please ignore that last message,  gmail webclient doesn't show the
subject when hitting reply missed that ..  sorry!



On Thu, Mar 5, 2015 at 7:04 PM, Thomas Lynch <
thomas.ly...@reasoningtechnology.com> wrote:

> I have the following error for a variable name that is used often in a
> large file,  Is there a way to coerce racket into telling me a function
> name or line number?
>
>
>

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] racket error message line number

2015-03-05 Thread Thomas Lynch
oh gosh, didn't edit the subject ...

anyway, found the offender, bad id anyway ... still error message without
line numbers are no fun.



On Thu, Mar 5, 2015 at 7:04 PM, Thomas Lynch <
thomas.ly...@reasoningtechnology.com> wrote:

> I have the following error for a variable name that is used often in a
> large file,  Is there a way to coerce racket into telling me a function
> name or line number?
>
>
> rac...@dataplex-lib.rkt> (enter! "dataplex-lib.rkt")
>   [re-loading /home/deep/src/dataplex-lib.rkt]
> expand: unbound identifier in module in: value
>
>
>  === context ===
> /usr/share/racket/collects/errortrace/errortrace-lib.rkt:399:2:
> errortrace-annotate
> /usr/share/racket/collects/errortrace/errortrace-lib.rkt:442:4
> /usr/share/racket/collects/racket/enter.rkt:67:2
> /usr/share/racket/collects/racket/enter.rkt:33:0: do-enter!
> /usr/share/racket/collects/racket/private/misc.rkt:87:7
>
>
>
>>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] CFP: Workshop on Generic Programming 2015 - Deadline May 15

2015-03-05 Thread Thomas Lynch
I have the following error for a variable name that is used often in a
large file,  Is there a way to coerce racket into telling me a function
name or line number?


rac...@dataplex-lib.rkt> (enter! "dataplex-lib.rkt")
  [re-loading /home/deep/src/dataplex-lib.rkt]
expand: unbound identifier in module in: value


 === context ===
/usr/share/racket/collects/errortrace/errortrace-lib.rkt:399:2:
errortrace-annotate
/usr/share/racket/collects/errortrace/errortrace-lib.rkt:442:4
/usr/share/racket/collects/racket/enter.rkt:67:2
/usr/share/racket/collects/racket/enter.rkt:33:0: do-enter!
/usr/share/racket/collects/racket/private/misc.rkt:87:7


On Thu, Mar 5, 2015 at 6:13 PM, Sebastian Erdweg <
erd...@informatik.tu-darmstadt.de> wrote:

> ==
>   CALL FOR PAPERS
>
>   WGP 2015
>
>11th ACM SIGPLAN Workshop on Generic Programming
>  Vancouver, Canada
>Sunday, August 30, 2015
>
>http://www.wgp-sigplan.org/2015
>
>  Co-located with the
>International Conference on Functional Programming (ICFP 2015)
> ==
>
>
> Goals of the workshop
> -
>
> Generic programming is about making programs more adaptable by making
> them more general. Generic programs often embody non-traditional kinds
> of polymorphism; ordinary programs are obtained from them by suitably
> instantiating their parameters. In contrast with normal programs, the
> parameters of a generic program are often quite rich in structure; for
> example they may be other programs, types or type constructors, class
> hierarchies, or even programming paradigms.
>
> Generic programming techniques have always been of interest, both to
> practitioners and to theoreticians, and, for at least 20 years,
> generic programming techniques have been a specific focus of research
> in the functional and object-oriented programming communities. Generic
> programming has gradually spread to more and more mainstream
> languages, and today is widely used in industry. This workshop brings
> together leading researchers and practitioners in generic programming
> from around the world, and features papers capturing the state of the
> art in this important area.
>
> We welcome contributions on all aspects, theoretical as well as
> practical, of
>
>  * generic programming,
>  * programming with (C++) concepts,
>  * meta-programming,
>  * programming with type classes,
>  * programming with modules,
>  * programming with dependent types,
>  * type systems for generic programming,
>  * polytypic programming,
>  * adaptive object-oriented programming,
>  * component-based programming,
>  * strategic programming,
>  * aspect-oriented programming,
>  * family polymorphism,
>  * object-oriented generic programming,
>  * implementation of generic programming languages,
>  * static and dynamic analyses of generic programs,
>  * and so on.
>
> Program Committee
> -
>
>  * Patrick Bahr (co-chair), University of Copenhagen
>  * Sebastian Erdweg (co-chair), Technical University of Darmstadt
>  * Edwin Brady, University of St Andrews
>  * Edsko de Vries, Well-Typed LLP
>  * Mauro Jaskelioff, National University of Rosario
>  * Johan Jeuring, Utrecht University
>  * Pieter Koopman, Radboud University Nijmegen
>  * Bruno C. d. S. Oliveira, University of Hong Kong
>  * Nicolas Pouillard, IT University of Copenhagen
>  * Sukyoung Ryu, Korea Advanced Institute of Science and Technology
>  * Sibylle Schupp, Hamburg University of Technology
>  * Sam Tobin-Hochstadt, Indiana University
>
> Proceedings and Copyright
> -
>
> We plan to have formal proceedings, published by the ACM. Accepted
> papers will be included in the ACM Digital Library. Authors must grant
> ACM publication rights upon acceptance
> (http://authors.acm.org/main.html), but may retain copyright if they
> wish. Authors are encouraged to publish auxiliary material with their
> paper (source code, test data, and so forth). The proceedings will be
> freely available for download from the ACM Digital Library from one
> week before the start of the conference until two weeks after the
> conference.
>
> Submission details
> --
>
>  * Submission deadline:  Fri, 15th May 2015
>  * Author notification:  Fri, 26th June 2015
>  * Final version due:Sun, 19th July 2015
>  * Workshop: Sun, 30th August 2015
>
> Submitted papers should fall into one of two categories:
>
>  * Regular research papers (12 pages)
>  * Short papers: case studies, tool demos, generic pearls (6 pages)
>
> Regular research papers are expected to present novel and interesting
> research results. Short papers need not present novel or fully polished
> results. Good candidates for short papers are those that 

Re: [racket] racket/db exception handling and unmanaged transactions with postgres

2015-01-20 Thread Thomas Lynch
p.s. here is my as-transaction macro for wrapping code in transaction
blocks.  The idea here is to make sure transactions begin and
commit/rollback is paired even in the presence of exceptions.  This macro
also deals with sharing the connection between threads, thus the
semaphore.  The db calls can be replaced with query calls simply enough to
use the racket/db library directly.  I don't mind doing a little
computation that otherwise might be outside the block within the
transaction block because the network delays of the query will dominate the
harmonic mean of the total performance.


 Perhaps someone will find this useful:

;;
;;  a transaction environment
;;
;;sets semaphore so no other transaction environment will use the db
connection
;;starts a transaction, and rolls it back if there is an exception,
otherwise closes it
;;
;;  (as-transaction body ...)
;;
  (define-syntax (as-transaction stx)
(syntax-case stx ()
  [(as-transaction body ...)
#`(begin
(semaphore-wait (current-db-semaphore))
(db-begin)
(begin0
 (with-handlers
   (
 [(lambda (v) #t) ; this handler catches anything
   (lambda (v)
 (db-rollback)
 (semaphore-post (current-db-semaphore))
 (raise v)
 )
   ]
 )
   body ...
   )
  (db-commit)
  (semaphore-post (current-db-semaphore))
))
]
  ))





On Wed, Jan 21, 2015 at 1:29 PM, Thomas Lynch <
thomas.ly...@reasoningtechnology.com> wrote:

> Thankyou Ryan.  I also changed to the managed transaction approach and it
> is working well.  It is a great library, and simple to use.
>
> IMHO the library should not do a rollback or require one after an
> exception, as a query failure is information that can be acted on, i.e. a
> program might use the information that the query failed to take different
> actions within the same transaction - as George mentions above.  I don't
> know if the server side is good with that, seems it would be.  .. but you
> already knew that and well I'm not doing it here so the issue is only moot
> for us.  Right now I'm glad to just not lock up the connection.  Thanks.
>
> I can imagine cases of a racket program relaying canned SQL that has
> 'unmanaged' transactions embedded in it.  Perhaps this SQL is just taken
> from files used in other applications before, perhaps from a cut and paste
> job into racket, or perhaps the SQL comes in real time from libraries,
> especially foreign libraries.  Perhaps such transactions could even be
> embedded in server side psql programs.  Don't know if if this latter case
> matters for racket/db library as it would all happen server side.
>
> Now what would be really nice is server side racket!  Let me send lambdas
> over there to later invoked multiple times with operands to perform query
> get, react, insert code locally instead of dumping that across the slow
> network layer of the OSI stack.   .. this sort of thing keeps me up nights
> ;-)
>
> Thomas
>
>
>
>
>
>
>
> On Wed, Jan 21, 2015 at 1:04 AM, Ryan Culpepper  wrote:
>
>> On 01/20/2015 06:53 AM, Thomas Lynch wrote:
>>
>>>
>>> According to the manual,
>>> http://docs.racket-lang.org/db/query-api.html#%28part._transactions%29,
>>>   section
>>> 3.5,  postgres transactions can be issued directly in SQL (so called
>>> 'unmanaged').   Here is a short code segment that fails doing unmanaged
>>> transactions (and nothing else).
>>>
>>> My question here is whether this code is doing unmanaged transactions
>>> correctly, and they are not working as advertised, or if there is
>>> something left out like an explicit reset to the connection after it
>>> throws an exception.
>>>
>>> For purposes of illustration, I run the following query here in the psql
>>> shell to show the the error message that it correctly issues:
>>>
>>> => insert into x_unique_counters values ('table_author','1');
>>> ERROR:  duplicate key value violates unique constraint
>>> "x_unique_counters_pkey"
>>> DETAIL:  Key (name)=(table_author) already exists.
>>>
>>>
>>> Now the racket program is ready for this kind of problem, here
>>> 'the-query' is the same query just shown above, but this time issued
>>> from this code
>>>
>>>
>>> (begin
>>>  

Re: [racket] racket/db exception handling and unmanaged transactions with postgres

2015-01-20 Thread Thomas Lynch
Thankyou Ryan.  I also changed to the managed transaction approach and it
is working well.  It is a great library, and simple to use.

IMHO the library should not do a rollback or require one after an
exception, as a query failure is information that can be acted on, i.e. a
program might use the information that the query failed to take different
actions within the same transaction - as George mentions above.  I don't
know if the server side is good with that, seems it would be.  .. but you
already knew that and well I'm not doing it here so the issue is only moot
for us.  Right now I'm glad to just not lock up the connection.  Thanks.

I can imagine cases of a racket program relaying canned SQL that has
'unmanaged' transactions embedded in it.  Perhaps this SQL is just taken
from files used in other applications before, perhaps from a cut and paste
job into racket, or perhaps the SQL comes in real time from libraries,
especially foreign libraries.  Perhaps such transactions could even be
embedded in server side psql programs.  Don't know if if this latter case
matters for racket/db library as it would all happen server side.

Now what would be really nice is server side racket!  Let me send lambdas
over there to later invoked multiple times with operands to perform query
get, react, insert code locally instead of dumping that across the slow
network layer of the OSI stack.   .. this sort of thing keeps me up nights
;-)

Thomas







On Wed, Jan 21, 2015 at 1:04 AM, Ryan Culpepper  wrote:

> On 01/20/2015 06:53 AM, Thomas Lynch wrote:
>
>>
>> According to the manual,
>> http://docs.racket-lang.org/db/query-api.html#%28part._transactions%29,
>>   section
>> 3.5,  postgres transactions can be issued directly in SQL (so called
>> 'unmanaged').   Here is a short code segment that fails doing unmanaged
>> transactions (and nothing else).
>>
>> My question here is whether this code is doing unmanaged transactions
>> correctly, and they are not working as advertised, or if there is
>> something left out like an explicit reset to the connection after it
>> throws an exception.
>>
>> For purposes of illustration, I run the following query here in the psql
>> shell to show the the error message that it correctly issues:
>>
>> => insert into x_unique_counters values ('table_author','1');
>> ERROR:  duplicate key value violates unique constraint
>> "x_unique_counters_pkey"
>> DETAIL:  Key (name)=(table_author) already exists.
>>
>>
>> Now the racket program is ready for this kind of problem, here
>> 'the-query' is the same query just shown above, but this time issued
>> from this code
>>
>>
>> (begin
>>  (semaphore-wait (current-db-semaphore))
>>  (query-exec pgc  "begin")
>>  (begin0
>>   (with-handlers
>> (
>>   [(lambda (v) #t) ; this handler catches anything
>> (lambda (v)
>>   (query-exec pgc "rollback")
>>   (semaphore-post (current-db-semaphore))
>>   (raise v)
>>   )
>> ]
>>   )
>>
>> (query-exec pgc the-query) ; this throws an exception
>>
>> )
>>(db-exec "commit")
>>(semaphore-post (current-db-semaphore))
>>  ))
>>  ]
>>))
>>
>>
>> So when query-exec throws an exception, the handler grabs it.  Then the
>> handler executes an SQL rollback to cancel the transaction.  All appears
>> to be good, but then bang!  we get an exception in the handler while
>> doing the rollback:
>>
>>  >(db-exec* '("rollback"))
>> query-exec: current transaction is invalid
>>
>>
>> All attempts to do any further queries on the connection fail with the
>> same error.   It appears to be foo-bar and a new connection must be made
>> before any further SQL can be issued against the database.
>>
>> Hmm, what is going on here?  Unmanaged connections not working as
>> advertised .. or some switch that must be flipped to tell the connection
>> to work again?
>>
>
> That looks like a bug in the db library. It rejects all queries when the
> transaction is invalid, rather than allowing rollbacks through.
>
> A workaround is to use (rollback-transaction pgc) in the exception
> handler. Despite what the docs say, it's okay to use rollback-transaction
> on a unmanaged transaction. I'll fix the docs.
>
> Ryan
>
>

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] racket/db exception handling and unmanaged transactions with postgres

2015-01-20 Thread Thomas Lynch
According to the manual,
http://docs.racket-lang.org/db/query-api.html#%28part._transactions%29,
 section
3.5,  postgres transactions can be issued directly in SQL (so called
'unmanaged').   Here is a short code segment that fails doing unmanaged
transactions (and nothing else).

My question here is whether this code is doing unmanaged transactions
correctly, and they are not working as advertised, or if there is something
left out like an explicit reset to the connection after it throws an
exception.

For purposes of illustration, I run the following query here in the psql
shell to show the the error message that it correctly issues:

=> insert into x_unique_counters values ('table_author','1');
ERROR:  duplicate key value violates unique constraint
"x_unique_counters_pkey"
DETAIL:  Key (name)=(table_author) already exists.


Now the racket program is ready for this kind of problem, here 'the-query'
is the same query just shown above, but this time issued from this code


   (begin
(semaphore-wait (current-db-semaphore))
(query-exec pgc  "begin")
(begin0
 (with-handlers
   (
 [(lambda (v) #t) ; this handler catches anything
   (lambda (v)
 (query-exec pgc "rollback")
 (semaphore-post (current-db-semaphore))
 (raise v)
 )
   ]
 )

   (query-exec pgc the-query) ; this throws an exception

   )
  (db-exec "commit")
  (semaphore-post (current-db-semaphore))
))
]
  ))


So when query-exec throws an exception, the handler grabs it.  Then the
handler executes an SQL rollback to cancel the transaction.  All appears to
be good, but then bang!  we get an exception in the handler while doing the
rollback:

>(db-exec* '("rollback"))
query-exec: current transaction is invalid


All attempts to do any further queries on the connection fail with the same
error.   It appears to be foo-bar and a new connection must be made before
any further SQL can be issued against the database.

Hmm, what is going on here?  Unmanaged connections not working as
advertised .. or some switch that must be flipped to tell the connection to
work again?

-Thomas

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] trace: set!: cannot mutate module-required identifier - alright .. how do you do this?

2015-01-20 Thread Thomas Lynch
p.s. add a separate regular old (provide ...)  for module interface
routines that are not traceable ...

On Tue, Jan 20, 2015 at 5:59 PM, Thomas Lynch <
thomas.ly...@reasoningtechnology.com> wrote:

> Alright, here is one solution to the trace of libraries.
>
> The following is macro definition for a type of model provide statement
> that allows toggling on and off trace for the provided routines.  Instead
> of using (provide x y z)  you use (provide-with-trace "my-lib" x y z).
> Then the functions (my-lib-trace) will turn on tracing for x y and z,  and
> (my-lib-untrace) turns them off.  Use provide-with-trace only once per
> module.
>
> (provide-with-trace ...)  must be at the bottom of the module because the
> interface routines must be defined before trace can be turned on for them.
>   Note the provide statement must be at module top level scope - not the
> top of the file, not the same thing of course, and the macro handles this.
>
> Matthias would probably tell you to use a case match instead of pulling
> the args out of stx directly, while the docs tell you to use syntax-parse
> instead, so that the args can be put into syntax classes; however grabbing
> the args was the least of my worries here .. perhaps when I'm better at
> this ..
>
>
> ;;
> ;; defines a trace-able module interface
> ;;
> ;;  (interface "lib-name" provide-functions ...)
> ;;
> ;;   lib-name-trace to turn on tracing
> ;;   lib-name-untrace to turn off tracing
> ;;
>   (define-syntax (provide-with-trace stx)
> (let(
>[datum  (syntax->datum stx)]
>   )
>   (let(
> [prefix  (cadr datum)]
> [interface-functions (cddr datum)]
>)
> (let(
>   [name-trace-fun   (string->symbol (string-append prefix
> "-trace"))]
>   [name-untrace-fun (string->symbol (string-append prefix
> "-untrace"))]
>   )
>#|
>   (displayln name-trace-fun)
>   (displayln name-untrace-fun)
>|#
>   (let(
> [code-block `(begin)]
> [trace-require '(require racket/trace)]
> [trace-fun
>   (append
> '(define)
> (list (list name-trace-fun))
> (map (λ(e)`(trace ,e)) interface-functions)
> )
>   ]
> [untrace-fun
>   (append
> '(define)
> (list (list name-untrace-fun))
> (map (λ(e)`(untrace ,e)) interface-functions)
> )
>   ]
> [provide-calls (map (λ(e)`(provide ,e))
> interface-functions)]
> )
> #|
> (displayln code-block)
> (displayln trace-require)
> (displayln trace-fun)
> (displayln untrace-fun)
> (displayln provide-calls)
> |#
> (let*(
>[program
>  (append
>code-block
>(list trace-require)
>(list trace-fun)
>(list untrace-fun)
>provide-calls
>)
>  ]
>)
>   ;;(displayln program)
>   (datum->syntax stx program)
>   ))
>
>
>
> As an example for using this, we have removed all of the (provide f)
> statements from the top of our db-lib module (which is a variation of the
> standard one) and now instead at the bottom of the file we have:
>
>
> ;;
> ;; module interface
> ;;
>   (provide-with-trace "db-lib"
> db-init
> db-exec
> db-exec*
> db-value
> db-value*
> db-maybe-value
> db-maybe-value*
> db-row
> db-row*
> db-rows
> db-rows*
> db-list
> db-list*
> db-lib-trace
> db-lib-untrace
> )
>
>
> Now when debugging,  we type (db-lib-trace)  to turn on tracing of calls
> to the db-lib interface.  We call (db-lib-untrace) to turn the tracing off.
>
> We plan to use this approach for all modules.
>
> Seems to be working.  Hope someone finds this useful.
>
> -Thomas
>
>
>
> On Mon, Jan 19, 2015 at 11:31 PM, Thomas Lynch <
> thomas.ly...@reasoningtechnol

Re: [racket] trace: set!: cannot mutate module-required identifier - alright .. how do you do this?

2015-01-20 Thread Thomas Lynch
Alright, here is one solution to the trace of libraries.

The following is macro definition for a type of model provide statement
that allows toggling on and off trace for the provided routines.  Instead
of using (provide x y z)  you use (provide-with-trace "my-lib" x y z).
Then the functions (my-lib-trace) will turn on tracing for x y and z,  and
(my-lib-untrace) turns them off.  Use provide-with-trace only once per
module.

(provide-with-trace ...)  must be at the bottom of the module because the
interface routines must be defined before trace can be turned on for them.
  Note the provide statement must be at module top level scope - not the
top of the file, not the same thing of course, and the macro handles this.

Matthias would probably tell you to use a case match instead of pulling the
args out of stx directly, while the docs tell you to use syntax-parse
instead, so that the args can be put into syntax classes; however grabbing
the args was the least of my worries here .. perhaps when I'm better at
this ..

;;
;; defines a trace-able module interface
;;
;;  (interface "lib-name" provide-functions ...)
;;
;;   lib-name-trace to turn on tracing
;;   lib-name-untrace to turn off tracing
;;
  (define-syntax (provide-with-trace stx)
(let(
   [datum  (syntax->datum stx)]
  )
  (let(
[prefix  (cadr datum)]
[interface-functions (cddr datum)]
   )
(let(
  [name-trace-fun   (string->symbol (string-append prefix
"-trace"))]
  [name-untrace-fun (string->symbol (string-append prefix
"-untrace"))]
  )
   #|
  (displayln name-trace-fun)
  (displayln name-untrace-fun)
   |#
  (let(
[code-block `(begin)]
[trace-require '(require racket/trace)]
[trace-fun
  (append
'(define)
(list (list name-trace-fun))
(map (λ(e)`(trace ,e)) interface-functions)
)
  ]
[untrace-fun
  (append
'(define)
(list (list name-untrace-fun))
(map (λ(e)`(untrace ,e)) interface-functions)
)
  ]
[provide-calls (map (λ(e)`(provide ,e))
interface-functions)]
)
#|
(displayln code-block)
(displayln trace-require)
(displayln trace-fun)
(displayln untrace-fun)
(displayln provide-calls)
|#
(let*(
   [program
 (append
   code-block
   (list trace-require)
   (list trace-fun)
   (list untrace-fun)
   provide-calls
   )
 ]
   )
  ;;(displayln program)
  (datum->syntax stx program)
  ))



As an example for using this, we have removed all of the (provide f)
statements from the top of our db-lib module (which is a variation of the
standard one) and now instead at the bottom of the file we have:

;;
;; module interface
;;
  (provide-with-trace "db-lib"
db-init
db-exec
db-exec*
db-value
db-value*
db-maybe-value
db-maybe-value*
db-row
db-row*
db-rows
db-rows*
db-list
db-list*
db-lib-trace
db-lib-untrace
)


Now when debugging,  we type (db-lib-trace)  to turn on tracing of calls to
the db-lib interface.  We call (db-lib-untrace) to turn the tracing off.

We plan to use this approach for all modules.

Seems to be working.  Hope someone finds this useful.

-Thomas



On Mon, Jan 19, 2015 at 11:31 PM, Thomas Lynch <
thomas.ly...@reasoningtechnology.com> wrote:

> please note, the simple example here is to facilitate discussion.  trace
> is being used very broadly for an entire development cycle.  This isn't a
> one time fix issue in general.
>
> I apologize if my original post wasn't clear, but I did modify the file
> that included "db-lib.rkt" as such:
>
>
> Saw this in another thread here, but the proposed solution didnt work,
>
> ...
>
> so I add this to "db-citation.rkt"
>
> (require racket/trace)
>
> (trace db-exec)
>
>
> And then at the prompt I get the following:
>
> Welcome to Racket v5.2.1.
>
> racket@> (enter! "db-citation.rkt")
>
> db-citation.rkt:26:11: set!: cannot mutate module-required identifier in:
> db-exec
>
>
> A

Re: [racket] trace: set!: cannot mutate module-required identifier - alright .. how do you do this?

2015-01-19 Thread Thomas Lynch
please note, the simple example here is to facilitate discussion.  trace is
being used very broadly for an entire development cycle.  This isn't a one
time fix issue in general.

I apologize if my original post wasn't clear, but I did modify the file
that included "db-lib.rkt" as such:


Saw this in another thread here, but the proposed solution didnt work,

...

so I add this to "db-citation.rkt"

(require racket/trace)

(trace db-exec)


And then at the prompt I get the following:

Welcome to Racket v5.2.1.

racket@> (enter! "db-citation.rkt")

db-citation.rkt:26:11: set!: cannot mutate module-required identifier in:
db-exec


Alright, so what is the magic incantation here that allows one to
debug/trace calls in included modules?

And was trying to implement Vince's solution and was asking why the above
didn't work.

I also tried going to the library source and adding at the top:

(require racket/trace)
(trace db-exec)

Running this again just now, I see that this gives me an error of

racket@> (enter! "db-citation.rkt")

... and own in the regression tests ..>

hooking test: drop-end-chars-test-0
link: reference (phase 0) to a variable in module
"/home/deep/src/db-lib.rkt" that is uninitialized (phase level 0);
reference appears in module: "/home/deep/src/db-citation.rkt" in: db-exec

 === context ===
/home/deep/src/db-citation.rkt: [running body]
/usr/share/racket/collects/racket/enter.rkt:33:0: do-enter!
/usr/share/racket/collects/racket/private/misc.rkt:87:7


Which is a big hint,  I moved the traces to the bottom of the file, yes and
now they work!  Thanks.

Top of the library file:

(require racket/trace)


Bottom of the library I copy all of the provides from the top, and then do
a text replace with the "provide"-> "trace" and thus:

(trace db-exec)
(trace db-rows)
...

Yes, and now calls to the library are tracing.   So to trace calls to a
library, one edits the library, puts the require at the top, copies all the
provides to the bottom, edits that to change the provides to trace, and
then off it goes.  .. could wrap the trace calls in a parameter switch
(current-db-trace) or some such...


On Mon, Jan 19, 2015 at 11:03 PM, J. Ian Johnson  wrote:

> To be fair, trace is more than that.
>
> Vincent's solution does work, but you have to modify the file - you can't
> do this from the REPL.
> You can modify the file containing the identifier you want to trace, if
> changing call sites is not palatable to you. Add `(require racket/trace)`
> at the top, and after the function definition `(trace function)`.
> Alternatively, if you only want to trace at given points in time, define
> and provide a function `(define (add-trace) (trace function))` so you can
> call `add-trace` when you want to turn on tracing.
>
> A missing feature for racket/trace is to provide a setter function so that
> modules that export a mutating function can be traced without depending on
> racket/trace. If a module contains a `set!` for an identifier, it disables
> any inlining for that identifier.
> e.g.
> (trace #:setter set-function!)
>
> -Ian
>
> - Original Message -
> From: "Thomas Lynch" 
> To: "J. Ian Johnson" 
> Cc: "users" 
> Sent: Monday, January 19, 2015 9:49:51 AM
> Subject: Re: [racket] trace: set!: cannot mutate module-required
> identifier - alright .. how do you do this?
>
> So to trace calls to the interface functions of a library I am to write a
> gasket for the library.  I may as well put a display of the args in the
> gasket functions as at this point it is the same amount of code as hooking
> the trace.   Of course then I have implemented trace.
>
> So to use trace in racket all you have to do is implement trace ..
> really??
>
> On Mon, Jan 19, 2015 at 10:06 PM, J. Ian Johnson  wrote:
>
> > Yes, racket 101 (305?) is that identifiers can only be set!'d in their
> > defining module. This is to allow necessary optimizations such as
> inlining.
> >
> > If you want to trace `f` from a different module. you can `(define (g .
> > args) (apply f args)) (trace g)`, use `g` wherever you use `f`. You won't
> > get any calls the library makes internally, but if you're just tracing
> for
> > your own code, you'll be golden.
> >
> > -Ian
> >
> > - Original Message -
> > From: "Thomas Lynch" 
> > To: "users" 
> > Sent: Monday, January 19, 2015 8:59:55 AM
> > Subject: [racket] trace: set!: cannot mutate module-required identifier -
> > alright .. how do you do this?
> >
> > Saw this in another thread here, but the proposed solution didnt work,
> > well at least the way

Re: [racket] trace: set!: cannot mutate module-required identifier - alright .. how do you do this?

2015-01-19 Thread Thomas Lynch
So to trace calls to the interface functions of a library I am to write a
gasket for the library.  I may as well put a display of the args in the
gasket functions as at this point it is the same amount of code as hooking
the trace.   Of course then I have implemented trace.

So to use trace in racket all you have to do is implement trace ..
really??

On Mon, Jan 19, 2015 at 10:06 PM, J. Ian Johnson  wrote:

> Yes, racket 101 (305?) is that identifiers can only be set!'d in their
> defining module. This is to allow necessary optimizations such as inlining.
>
> If you want to trace `f` from a different module. you can `(define (g .
> args) (apply f args)) (trace g)`, use `g` wherever you use `f`. You won't
> get any calls the library makes internally, but if you're just tracing for
> your own code, you'll be golden.
>
> -Ian
>
> - Original Message -
> From: "Thomas Lynch" 
> To: "users" 
> Sent: Monday, January 19, 2015 8:59:55 AM
> Subject: [racket] trace: set!: cannot mutate module-required identifier -
> alright .. how do you do this?
>
> Saw this in another thread here, but the proposed solution didnt work,
> well at least the way I understood it. So ..
>
> In file db-lib.rkt I have a definition:
>
>
>
>
> (provide db-exec)
> (define (db-exec a) ...)
>
> Then in racket
>
>
>
>
> > (enter! "db-user.rkt")
>
> Where db-citation.rkt has
>
>
>
>
> (require "db-lib.rkt")
>
> Now at the read-eval-print prompt I try
>
>
>
>
> (enter! "db-citation.rkt")
>
> And when I do (trace db-exec) I get the cannot mutate error. (Surely this
> must be a racket 101 type problem.) So I try to include the module at the
> current scope..
>
>
>
>
> rac...@db-citation.rkt> (require "db-lib.rkt")
> rac...@db-citation.rkt> (require racket/trace)
> rac...@db-citation.rkt> (trace db-exec)
>
> rac...@db-citation.rkt> stdin::1130: set!: cannot mutate module-required
> identifier in: db-exec
> ok, so that doesn't work, so I start over again. This time after reading
> the thread on this list
>
>
>
>
> From: Vincent St-Amour (stamourv at ccs.neu.edu )
> Date: Mon Oct 10 13:49:46 EDT 2011
>
> which concludes by saying 'put the trace in your program that should
> work', so I add this to "db-citation.rkt"
>
>
>
>
> (require racket/trace)
> (trace db-exec)
>
> And then at the prompt I get the following:
>
>
>
>
> Welcome to Racket v5.2.1.
> racket@> (enter! "db-citation.rkt")
> db-citation.rkt:26:11: set!: cannot mutate module-required identifier in:
> db-exec
>
> Alright, so what is the magic incantation here that allows one to
> debug/trace calls in included modules?
>
> Thanks!
>
> Thomas
>
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users
>

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] trace: set!: cannot mutate module-required identifier - alright .. how do you do this?

2015-01-19 Thread Thomas Lynch
Saw this in another thread here, but the proposed solution didnt work, well
at least the way I understood it.  So ..

In file db-lib.rkt  I have a definition:

(provide db-exec)
(define (db-exec a) ...)


Then in racket

> (enter! "db-user.rkt")


Where db-citation.rkt has

(require "db-lib.rkt")

Now at the read-eval-print prompt I try

(enter! "db-citation.rkt")


And when I do (trace db-exec)  I get the cannot mutate error.  (Surely this
must be a racket 101 type problem.)  So I try to include the module at the
current scope..

rac...@db-citation.rkt> (require "db-lib.rkt")
rac...@db-citation.rkt> (require racket/trace)
rac...@db-citation.rkt>(trace db-exec)

rac...@db-citation.rkt> stdin::1130: set!: cannot mutate module-required
identifier in: db-exec


ok, so that doesn't work,  so I start over again.  This time after reading
the thread on this list

From: Vincent St-Amour (stamourv at ccs.neu.edu)
Date: Mon Oct 10 13:49:46 EDT 2011

which concludes by saying 'put the trace in your program that should work',
  so I add this to "db-citation.rkt"

(require racket/trace)
(trace db-exec)


And then at the prompt I get the following:

Welcome to Racket v5.2.1.
racket@> (enter! "db-citation.rkt")
db-citation.rkt:26:11: set!: cannot mutate module-required identifier in:
db-exec


Alright, so what is the magic incantation here that allows one to
debug/trace calls in included modules?

Thanks!

Thomas

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] ok what's wrong there 'syntax-rule' evaluating its operand (??)

2015-01-15 Thread Thomas Lynch
thank you! ..  of course that makes sense.  I guess that gensym and
uninterned symbols have something to do with this?

The identifiers in the macro are 'interned' (is that the terminology?
rather than renamed?) so in fact table-auth was never defined.  Then at run
time there are complaints as such.  Most all macro expanders work this way,
though we might have some way to distinguish which identifiers get munged.

. so is there a simple way to communicate with  define-syntax-rule and tell
it not to íntern' certain identifiers in its body? ... '(native
table-author ...) or some such? ..  Of course there is always the
define-syntax.

On Thu, Jan 15, 2015 at 3:28 PM, Daniel Prager 
wrote:

> Hi Thomas
>
> IIUC you get an error with your original syntax-rules version because
> syntax-rules (and syntax-case and syntax-parse) is hygienic by default. In
> this case think of table-author etc. being renamed inside the macro to
> avoid clashing with variables defined in the calling code. Hence the
> undefined error in the calling code.
>
> You *want* and expect it to be defined by the macro, but the default
> behavior says otherwise, and needs to be explicitly over-ridden.
>
>
> Dan
>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] ok what's wrong there 'syntax-rule' evaluating its operand (??)

2015-01-14 Thread Thomas Lynch
oops sorry Daniel, I already put it over on the developers list.

The question is about the context and place of evaluation for
'table-author' and when it caused an error.  Tha question never got
addressed here.  However we did have a lot of "user" type answers..  seems
it belongs on the developers list.

I'll post back on the list here if I get a simple answer over there ..

On Thu, Jan 15, 2015 at 2:14 PM, Daniel Prager 
wrote:

> Hi Thomas
>
> Can we please keep the discussion going here on the racket users list, for
> those -- like me -- who are following along and finding the discussion
> illuminating?
>
>
> Thanks
>
> Dan
>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] ok what's wrong there 'syntax-rule' evaluating its operand (??)

2015-01-14 Thread Thomas Lynch
I reformulated/clarified the question and bumped it over to the developers,
you can find it there.  Thanks for helping with this.

On Thu, Jan 15, 2015 at 12:46 PM, Thomas Lynch <
thomas.ly...@reasoningtechnology.com> wrote:

> Matthias,
>
> I appreciate your patience.  I did see the 'pattern better than direct
> access' and other style discussion on a tutorial on the net, and I do get
> that.  The first macro presented in the original post was to show the
> desired behavior and to show the code runs without errors.  This stands in
> contrast to the define-syntax-rule example, which throws an error - note
> the subject of my post.
>
> You haven't commented on the error or why the syntax rule evaluates the
> operand.  If "macros do not evaluate anything", which was my expectation
> also, and the expansion occurs in hygienically at the scope of the let at
> run time, which was also my expectation,  then where is the 'undefined
> identifier' error coming from?
>
> You can see the error thrown by running the define-syntax-rule example, as
> shown in the original post along with its output.
>
> Thomas
>
>
>
> On Thu, Jan 15, 2015 at 12:07 PM, Matthias Felleisen  > wrote:
>
>>
>> [cc user@ again]
>>
>> There is no bug in syntax-rule/s.
>>
>> Macros do not evaluate anything. They rewrite code. Code refers to
>> identifiers. This relation must remain apparent.
>>
>> That's it. -- Matthias
>>
>>
>>
>>
>>
>>
>> On Jan 14, 2015, at 9:57 PM, Thomas Lynch wrote:
>>
>> As for the demonstrative example at the top of the original post, I now
>> understand you are speaking of clarity and style rather than a functional
>> problem with it. I enjoyed that discussion on clarity, intention, and
>> aesthetics.
>>
>> As for the question of why the 'body' argument is being evaluated as an
>> operand rather as part of the expansion, and thus resulting in an undefined
>> identifier error, am I correct to read your answer above, that this is
>> indeed a bug?  "macro-site variables are bound by macro-contexts" but
>> clearly that is not happening - or the error wouldn't be issued.
>>
>> IMHO the define-syntax-rule would be the clearest implementation for the
>> reader for the reasons you give.  Too bad there is a bug in it.  (The
>> operand should not be evaluated except as part of the macro expansion, as
>> you note.  I am reading you on this correctly?  I have a hard time
>> understanding why an operand to a macro would be evaluated before it is
>> included in the expansion, unless it was a limitation of the interpreter,
>> but if it is a bug, then good as it can be fixed.)
>>
>> On Thu, Jan 15, 2015 at 9:53 AM, Matthias Felleisen > > wrote:
>>
>>>
>>> On Jan 14, 2015, at 8:14 PM, Thomas Lynch wrote:
>>>
>>> Matthias thank you for fielding my question, though two things are not
>>> clear.  I hope you or someone might clarify.
>>>
>>> Firstly,  is there a reason to prefer the macro you present over the
>>> first one given in the original post.  I believe they both work.  Neither
>>> uses the more elegant syntax-rule.
>>>
>>>
>>>
>>> Code that works is fine. Code that clearly explains its intention is
>>> better. Since syntactic extensions are (basically) extensions to the
>>> grammar, their specification ought to bring across (a) what kind of new
>>> expressions programmers may write down and (b) what these new expressions
>>> mean. I think separating these cleanly is also important.
>>>
>>> With syntax-case, which isn't all that different from syntax-rules, you
>>> get (a) easily:
>>>
>>>   (with-tables stem body ...)
>>>
>>> Compare this to your three or four lines that stx apart. When your
>>> extension is even more complicated, you definitely want this pattern
>>> matching notation because it is close to the way people write grammars and
>>> because you can automatically check certain properties (see syntax-parse).
>>>
>>> For (b), constructing a piece of syntax manually with backquote, comma,
>>> splice is again much more complicated than writing down a rewrite rule. In
>>> particular, you get a really good handle at the manipulation of scope,
>>> which is one of the primary functions of syntactic extensions.
>>>
>>> Racket like Scheme like Lisp is about being able abstract boiler plate.
>>> Syntax-case abstracts your boiler plate 

Re: [racket] ok what's wrong there 'syntax-rule' evaluating its operand (??)

2015-01-14 Thread Thomas Lynch
Matthias,

I appreciate your patience.  I did see the 'pattern better than direct
access' and other style discussion on a tutorial on the net, and I do get
that.  The first macro presented in the original post was to show the
desired behavior and to show the code runs without errors.  This stands in
contrast to the define-syntax-rule example, which throws an error - note
the subject of my post.

You haven't commented on the error or why the syntax rule evaluates the
operand.  If "macros do not evaluate anything", which was my expectation
also, and the expansion occurs in hygienically at the scope of the let at
run time, which was also my expectation,  then where is the 'undefined
identifier' error coming from?

You can see the error thrown by running the define-syntax-rule example, as
shown in the original post along with its output.

Thomas



On Thu, Jan 15, 2015 at 12:07 PM, Matthias Felleisen 
wrote:

>
> [cc user@ again]
>
> There is no bug in syntax-rule/s.
>
> Macros do not evaluate anything. They rewrite code. Code refers to
> identifiers. This relation must remain apparent.
>
> That's it. -- Matthias
>
>
>
>
>
>
> On Jan 14, 2015, at 9:57 PM, Thomas Lynch wrote:
>
> As for the demonstrative example at the top of the original post, I now
> understand you are speaking of clarity and style rather than a functional
> problem with it. I enjoyed that discussion on clarity, intention, and
> aesthetics.
>
> As for the question of why the 'body' argument is being evaluated as an
> operand rather as part of the expansion, and thus resulting in an undefined
> identifier error, am I correct to read your answer above, that this is
> indeed a bug?  "macro-site variables are bound by macro-contexts" but
> clearly that is not happening - or the error wouldn't be issued.
>
> IMHO the define-syntax-rule would be the clearest implementation for the
> reader for the reasons you give.  Too bad there is a bug in it.  (The
> operand should not be evaluated except as part of the macro expansion, as
> you note.  I am reading you on this correctly?  I have a hard time
> understanding why an operand to a macro would be evaluated before it is
> included in the expansion, unless it was a limitation of the interpreter,
> but if it is a bug, then good as it can be fixed.)
>
> On Thu, Jan 15, 2015 at 9:53 AM, Matthias Felleisen 
> wrote:
>
>>
>> On Jan 14, 2015, at 8:14 PM, Thomas Lynch wrote:
>>
>> Matthias thank you for fielding my question, though two things are not
>> clear.  I hope you or someone might clarify.
>>
>> Firstly,  is there a reason to prefer the macro you present over the
>> first one given in the original post.  I believe they both work.  Neither
>> uses the more elegant syntax-rule.
>>
>>
>>
>> Code that works is fine. Code that clearly explains its intention is
>> better. Since syntactic extensions are (basically) extensions to the
>> grammar, their specification ought to bring across (a) what kind of new
>> expressions programmers may write down and (b) what these new expressions
>> mean. I think separating these cleanly is also important.
>>
>> With syntax-case, which isn't all that different from syntax-rules, you
>> get (a) easily:
>>
>>   (with-tables stem body ...)
>>
>> Compare this to your three or four lines that stx apart. When your
>> extension is even more complicated, you definitely want this pattern
>> matching notation because it is close to the way people write grammars and
>> because you can automatically check certain properties (see syntax-parse).
>>
>> For (b), constructing a piece of syntax manually with backquote, comma,
>> splice is again much more complicated than writing down a rewrite rule. In
>> particular, you get a really good handle at the manipulation of scope,
>> which is one of the primary functions of syntactic extensions.
>>
>> Racket like Scheme like Lisp is about being able abstract boiler plate.
>> Syntax-case abstracts your boiler plate for (a) and (b).
>>
>> Ideally, I would like to separate (a) from (b) so that programmers can
>> specify (a) at the module boundary, just like contracts for functions.
>> That's what I started Ryan on and we ended up syntax-parse. It' s a
>> fantastic first step but there is work left to do. Probably another
>> dissertation.
>>
>>
>> Secondly, and this is the question I'm really getting at,  is there a
>> reason that the operands given to syntax-rules must have identifiers within
>> lexical scope at the point of the macro call, rather than lexical scope at
>>

Re: [racket] ok what's wrong there 'syntax-rule' evaluating its operand (??)

2015-01-14 Thread Thomas Lynch
Matthias thank you for fielding my question, though two things are not
clear.  I hope you or someone might clarify.

Firstly,  is there a reason to prefer the macro you present over the first
one given in the original post.  I believe they both work.  Neither uses
the more elegant syntax-rule.

Secondly, and this is the question I'm really getting at,  is there a
reason that the operands given to syntax-rules must have identifiers within
lexical scope at the point of the macro call, rather than lexical scope at
the point of their use within the macro?

Off hand the latter seems to be the proper behavior for a macro,  i.e.
perhaps this is a bug?  Can anyone here tell me why it behaves like this?


On Thu, Jan 15, 2015 at 4:12 AM, Matthias Felleisen 
wrote:

>
> You want something like this:
>
> (define-syntax (with-tables stx)
>   (syntax-case stx ()
> [(with-tables stem body ...)
>  (let ([table-author (datum->syntax stx 'table-author)]
>;; ... ditto for other identifiers for which you wish to break
> lexical scope
>)
>#`(let ([table-publication (string-append stem "_publication")]
>[#,table-author (string-append stem "_author")]
>[table-bridge-publication-author (string-append stem
> "_bridge_publication_author")]
>[table-unique-counters (string-append stem
> "_unique_counters")])
>body ...))]))
>
> (with-tables "x" table-author)
>
> ;; ---
>
> To achieve this with syntax-rules would be, well, hard.
>
> ;; ---
>
> The accepted way of writing this macro is:
>
> (define-syntax (with-tables stx)
>   (syntax-case stx ()
> [(with-tables stem (table-author
> ;; ... add other names you wish to bind in body
> )
>   body ...)
>  #`(let ([table-publication (string-append stem "_publication")]
>  [table-author (string-append stem "_author")]
>  [table-bridge-publication-author (string-append stem
> "_bridge_publication_author")]
>  [table-unique-counters (string-append stem
> "_unique_counters")])
>body ...)]))
>
> (with-tables "x" (table-author) table-author)
>
>
>
>

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] ok what's wrong there 'syntax-rule' evaluating its operand (??)

2015-01-14 Thread Thomas Lynch
Here is a macro that is working, .. at least in the context it is being
used:

  (define-syntax (with-tables stx)
(let*(
   [datum  (syntax->datum stx)]
   [stem   (cadr datum)]
   [body   (cddr datum)]
   )
  (datum->syntax stx
(append
  `(let(
 [table-publication (string-append ,stem "_publication")]
 [table-author (string-append ,stem "_author")]
 [table-bridge-publication-author (string-append ,stem
"_bridge_publication_author")]
 [table-unique-counters (string-append ,stem
"_unique_counters")]
 ))
  body
  )

racket@> (with-tables "x" (displayln table-publication) table-author)
x_publication
"x_author"



This same functionality as a syntax rule:

 (define-syntax with-tables
(syntax-rules ()
  [(with-tables stem body ...)
(let(
  [table-publication (string-append stem "_publication")]
  [table-author (string-append stem "_author")]
  [table-bridge-publication-author (string-append stem
"_bridge_publication_author")]
  [table-unique-counters (string-append stem
"_unique_counters")]
  )
  body ...
  )
]
  ))

   #|
racket@> (with-tables "x" table-author)
reference to undefined identifier: table-author
stdin::6353: table-author
 === context ===
/usr/share/racket/collects/racket/private/misc.rkt:87:7
   |#



Fails with a undefined identifier, but to do that it would have to evaluate
the argument.   Ok, so what did I do wrong here?

..not surprisingly, same result with define-syntax-rule ..

 (define-syntax-rule (with-tables stem body ...)
  (let(
[table-publication (string-append stem "_publication")]
[table-author (string-append stem "_author")]
[table-bridge-publication-author (string-append stem
"_bridge_publication_author")]
[table-unique-counters (string-append stem "_unique_counters")]
)
body ...
))

  #|
racket@> (with-tables "x" table-author)
reference to undefined identifier: table-author
stdin::6353: table-author
 === context ===
/usr/share/racket/collects/racket/private/misc.rkt:87:7
  |#


-Thomas

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] postgres connect problem - unexpected 'password required' error

2015-01-01 Thread Thomas Lynch
Thank you, that is good information.  The SSL performance issue is
important and I didn't even know to ask about it.  Thanks also to Ryan.

On Fri, Jan 2, 2015 at 12:12 AM, Neil Van Dyke  wrote:

> Thomas Lynch wrote on 01/01/2015 10:32 AM:
>
>>
>> I don't know if there is an issue that caused the package to be
>> distributed with these config settings so I will go with the #:socket
>> `guess approach until I have a better understanding.
>>
>
> The Debian default settings for PG access are OK to start with, especially
> if it's just a single-user workstation, and not sensitive data.  If someone
> is setting up a PG server or handling sensitive data, they'll definitely
> want to have some understanding of what their access control settings are
> in `pg_hba.conf`.  A few-minute shortcut is to comment-out all the access
> method lines except the one or two that you think you use, then make sure
> you understand everything in that line or two.  Most of the other stuff is
> not relevant to most people.
>
> Another reason for programmers to look at `pg_hba.conf` at least once
> (though this doesn't affect you right now) is performance: the file
> specifies which access methods can/can't/may use SSL, and SSL can give you
> awful latency on each PG request.  Depending on `pg_hba.conf` settings, PG
> clients might silently use SSL on some systems without the programmer
> knowing it, and then programmer wonders why his/her database seems so slow.
>
> BTW, Ryan Culpepper, et al., did an excellent job on the Racket support
> for PostgreSQL.  This support is being used for some heavy and complicated
> PG access by some important systems.
>
> Neil V.
>
>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] postgres connect problem - unexpected 'password required' error

2015-01-01 Thread Thomas Lynch
So yes,  the Unix socket and TCP local connection are different in the
config file, one being peer, the other being 'md5'

I assume setting the tcp socket to peer in the pg_hba.conf file would work.

I just tested your suggestion of  "adding `#:socket 'guess` to your
`postgresql-connect` call" and that works.  Thank you!

I don't know if there is an issue that caused the package to be distributed
with these config settings so I will go with the #:socket `guess approach
until I have a better understanding.

BTW, the other contingency of "`#:ssl 'yes` to `postgresql-connect" had no
affect in this case.

Thank you !



On Thu, Jan 1, 2015 at 11:20 PM, Thomas Lynch <
thomas.ly...@reasoningtechnology.com> wrote:

>
>
> On Thu, Jan 1, 2015 at 6:25 PM, Neil Van Dyke 
> wrote:
>
>> Thomas Lynch wrote on 01/01/2015 03:30 AM:
>>
>>> I am having difficulty connecting to the postgres server from Racket.
>>> It asks for a password, but role and authentication is set up so that the
>>> logged in local user does not need one.
>>>
>>>
>> Is `psql` is using a Unix domain socket to talk to PG,
>> `postgresql-connect` is using a `localhost` TCP port to PG, and your
>> `/etc/postgresql/*/main/pg_hba.conf` is configured to have different
>> authentication for the two different methods?
>>
>
> By gosh you are correct, this is the default for pg_hba.conf with the
> debian package install:
>
>
>>
>> If so, try either adding `#:socket 'guess` to your `postgresql-connect`
>> call, or modifying your `pg_hba.conf` (and restarting PG).
>>
>> If that's not quite it, try also adding `#:ssl 'yes` to
>> `postgresql-connect`, or modifying `pg_hba.conf` again.
>>
>> If that's not it, check for PG environment variables that `psql` could be
>> using.  Also, you can test the different methods by supplying different
>> `conninfo` strings on the `psql` command line.
>>
>> Neil V.
>>
>>
>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] postgres connect problem - unexpected 'password required' error

2015-01-01 Thread Thomas Lynch
On Thu, Jan 1, 2015 at 6:25 PM, Neil Van Dyke  wrote:

> Thomas Lynch wrote on 01/01/2015 03:30 AM:
>
>> I am having difficulty connecting to the postgres server from Racket.  It
>> asks for a password, but role and authentication is set up so that the
>> logged in local user does not need one.
>>
>>
> Is `psql` is using a Unix domain socket to talk to PG,
> `postgresql-connect` is using a `localhost` TCP port to PG, and your
> `/etc/postgresql/*/main/pg_hba.conf` is configured to have different
> authentication for the two different methods?
>

By gosh you are correct, this is the default for pg_hba.conf with the
debian package install:


>
> If so, try either adding `#:socket 'guess` to your `postgresql-connect`
> call, or modifying your `pg_hba.conf` (and restarting PG).
>
> If that's not quite it, try also adding `#:ssl 'yes` to
> `postgresql-connect`, or modifying `pg_hba.conf` again.
>
> If that's not it, check for PG environment variables that `psql` could be
> using.  Also, you can test the different methods by supplying different
> `conninfo` strings on the `psql` command line.
>
> Neil V.
>
>

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] postgres connect problem - unexpected 'password required' error

2015-01-01 Thread Thomas Lynch
I am having difficulty connecting to the postgres server from Racket.  It
asks for a password, but role and authentication is set up so that the
logged in local user does not need one.

1. these versions:

(Debian 4.6.3-14)
Racket 5.2.1
postgres (9.1.14)


2. running psql from a shell prompt doesn't prompt for anything, just works:

> psql
psql (9.1.14)
Type "help" for help.

lynch=> \list
  List of databases
   Name|  Owner   | Encoding |   Collate   |Ctype|   Access
privileges
---+--+--+-+-+---
 lynch   | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
 postgres  | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
 template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres
 +
   |  |  | | |
postgres=CTc/postgres
 template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres
 +
   |  |  | | |
postgres=CTc/postgres
(4 rows)


3. running from racket however, gives an error, saying it needs a password:

racket@> (require db)
racket@> (define pgc (postgresql-connect #:database "lynch" #:user "lynch"))
postgresql-connect: password needed but not supplied
stdin::319: ((checked-procedure-check-and-extract struct:keyword-procedure
pgc keyword-procedure-extract (quote (#:database #:user)) (quote 2)) (quote
(#:database #:user)) (list temp7 temp8))



Ah, so what am I doing wrong here?

Thanks.

  Racket Users list:
  http://lists.racket-lang.org/users