Re: [racket-users] Class constracts and equality

2015-09-01 Thread Asumu Takikawa
Hi Konrad,

On 2015-09-01 20:42:42 +0200, Konrad Hinsen wrote:
> Thanks for the reference, but my interpretation of this is different. I
> don't care about eq?, nor about testing how objects were created. I want
> comparison by equal? by recursive application to the fields - just as for
> transparent structures.

It seems like the problem is that the wrappers that the class contract
installs does not take into account whether the original class has an
inspector of #f or not.

In particular, the code for class contracts explicitly installs a value for the
inspector that doesn't allow inspection (there's a comment saying "No
inspection").

But maybe it's worth revisiting this part of the design. I can look into if
it's possible to have the contracted class inherit the inspect of the original
and whether that causes any problems.

Cheers,
Asumu

-- 
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] Class constracts and equality

2015-09-01 Thread Konrad Hinsen

On 01/09/15 18:45, Daniel Feltey wrote:


I think this is expected, if you want to check for equality on instances
of contracted classes you should use the `object=?` function which can
"see through" the contract wrappers.

http://docs.racket-lang.org/reference/objectutils.html?q=object%3D%3F#%28def._%28%28lib._racket%2Fprivate%2Fclass-internal..rkt%29._object~3d~3f%29%29


Thanks for the reference, but my interpretation of this is different. I 
don't care about eq?, nor about testing how objects were created. I want 
comparison by equal? by recursive application to the fields - just as 
for transparent structures.


Konrad.

--
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] custom-print called twice?

2015-09-01 Thread Matthew Flatt
The first call is to detect sharing, and the second time is to actually
print.

For example, if you change `(constr 'y)` to

  (define b (box #f))
  (set-box! b (constr b))
  b

then you'll see that the output starts with "#0=", because the first
pass detected that a "#0#" will be needed.

At Wed, 2 Sep 2015 00:45:43 +0200, "Jos Koot" wrote:
> Question:
>  
> why is in the following example the custom-printer called twice?
>  
> #lang racket
>  
> (define n 0)
>  
> (letrec-values
>  (((printer)
>(λ (obj port mode)
> (set! n (add1 n))
> (fprintf port "#" (name obj
>   ((id constr pred acc mut)
>(make-struct-type 'x #f 1 0 #f
> (list (cons prop:custom-write printer
>   ((name) (make-struct-field-accessor acc 0 'name)))
>  (constr 'y)) ; -> #
>  
> n ; -> 2
>  
> ;Done with
> ;DrRacket, version 6.2.0.5--2015-07-06(d6fa581/a) [3m].
> ;Language: racket [custom]; memory limit: 2000 MB.
>  
> Best wishes, Jos Koot
> 
> -- 
> 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] TR + Vector containing opaque struct

2015-09-01 Thread Sam Tobin-Hochstadt
The best solution is usually to avoid using Any when interoperating with
untyped code. Presumably you can describe a more specific type for this
case, such as an opaque type for the sql-null value.

Sam

On Tue, Sep 1, 2015, 3:03 PM 'John Clements' via Racket Users <
racket-users@googlegroups.com> wrote:

> I’m trying to use the database library db with TR, and I’ve run into a
> problem whose only workaround seems really nasty.
>
> Specifically, it concerns vectors (or lists, presumably) that contain
> opaque values. So, for instance, here’s foo1.rkt:
>
> #lang racket
>
> (provide return-a-list)
>
> (struct my-struct ())
>
> (define (return-a-list)
>   (vector 13 (my-struct) 15))
>
> … and here’s foo2.rkt:
>
> #lang typed/racket
>
> (require/typed "foo1.rkt"
>[return-a-list (-> (Vectorof Any))])
>
> (return-a-list)
>
> Running foo2.rkt produces this error:
>
> . . return-a-list: contract violation
>   Attempted to use a higher-order value passed as `Any` in untyped code:
> #
>   in: an element of
>   the range of
>   (-> (vectorof Any))
>   contract from: (interface for return-a-list)
>   blaming: /private/tmp/foo2.rkt
>(assuming the contract is correct)
>   at: /private/tmp/foo2.rkt:4.16
>
> Making “my-struct” transparent solves this problem, but the problem arises
> for me in the use of db’s #, which I can’t mess with.
>
> Frankly, it looks like the easiest workaround is just … not to use TR
> here. Am I missing something obvious? Also, I’d love a bit more explanation
> of how this breaks TR’s type safety guarantee.
>
> Thanks!
>
> John
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] TR + Vector containing opaque struct

2015-09-01 Thread 'John Clements' via Racket Users
I’m trying to use the database library db with TR, and I’ve run into a problem 
whose only workaround seems really nasty.

Specifically, it concerns vectors (or lists, presumably) that contain opaque 
values. So, for instance, here’s foo1.rkt:

#lang racket

(provide return-a-list)

(struct my-struct ())

(define (return-a-list)
  (vector 13 (my-struct) 15))

… and here’s foo2.rkt:

#lang typed/racket

(require/typed "foo1.rkt"
   [return-a-list (-> (Vectorof Any))])

(return-a-list)

Running foo2.rkt produces this error:

. . return-a-list: contract violation
  Attempted to use a higher-order value passed as `Any` in untyped code: 
#
  in: an element of
  the range of
  (-> (vectorof Any))
  contract from: (interface for return-a-list)
  blaming: /private/tmp/foo2.rkt
   (assuming the contract is correct)
  at: /private/tmp/foo2.rkt:4.16

Making “my-struct” transparent solves this problem, but the problem arises for 
me in the use of db’s #, which I can’t mess with.

Frankly, it looks like the easiest workaround is just … not to use TR here. Am 
I missing something obvious? Also, I’d love a bit more explanation of how this 
breaks TR’s type safety guarantee.

Thanks!

John



-- 
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] custom-print called twice?

2015-09-01 Thread Jos Koot
Question:
 
why is in the following example the custom-printer called twice?
 
#lang racket
 
(define n 0)
 
(letrec-values
 (((printer)
   (λ (obj port mode)
(set! n (add1 n))
(fprintf port "#" (name obj
  ((id constr pred acc mut)
   (make-struct-type 'x #f 1 0 #f
(list (cons prop:custom-write printer
  ((name) (make-struct-field-accessor acc 0 'name)))
 (constr 'y)) ; -> #
 
n ; -> 2
 
;Done with
;DrRacket, version 6.2.0.5--2015-07-06(d6fa581/a) [3m].
;Language: racket [custom]; memory limit: 2000 MB.
 
Best wishes, Jos Koot

-- 
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] Help needed with: "cannot instantiate `racket/gui/base' a second time in the same process context"

2015-09-01 Thread Tiina Partanen
Hi,

I uploaded my very first package and scribble docs to the Racket package 
server.  It seems that there is something wrong in my scribble files since the 
docs don't show up and I get this error:
"cannot instantiate `racket/gui/base' a second time in the same process 
context"?

Here is the whole error log:
http://pkg-build.racket-lang.org/server/built/fail/teachpacks.txt 

And this is the package source:
https://github.com/tyynetyyne/teachpacks 

Can anyone help me with this?

Thanks,
Tiina


-- 
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] Help needed with: "cannot instantiate `racket/gui/base' a second time in the same process context"

2015-09-01 Thread Matthew Flatt
The problem is that the documentation-build process cannot support a
use (direct or indirect) of `racket/gui/base` at documentation-build
time. The

 @(require teachpacks/racket-turtle)

in your ".scrbl" files is the main problem, since that indirectly loads
`racket/gui/base`.

It looks like you were also trying to run `teachpacks/racket-turtle`
via `interactions`, which could cause similar trouble, but you've
resorted to re-rendering the images. That's essentially the only
answer, but the `scriblib/gui-eval` library can help generate the
images if `racket/gui/base` needs to run to generate the images.

If the images really only need `racket/draw`, then maybe you could
split the library so that the drawing part is separate from the GUI
part (i.e,. the drawing functions are in a module that doesn't
transitively import `racket/gui/base`. Then, you can use the drawing
part from the documentation, even if the library is meant to be used
with the GUI part.

At Tue, 1 Sep 2015 03:57:00 -0700 (PDT), Tiina Partanen wrote:
> Hi,
> 
> I uploaded my very first package and scribble docs to the Racket package 
> server.  It seems that there is something wrong in my scribble files since 
> the 
> docs don't show up and I get this error:
> "cannot instantiate `racket/gui/base' a second time in the same process 
> context"?
> 
> Here is the whole error log:
> http://pkg-build.racket-lang.org/server/built/fail/teachpacks.txt 
> 
> And this is the package source:
> https://github.com/tyynetyyne/teachpacks 
> 
> Can anyone help me with this?
> 
> Thanks,
> Tiina
> 
> 
> -- 
> 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] How to use the web-server package without continuations?

2015-09-01 Thread Jay McCarthy
On Tue, Sep 1, 2015 at 10:03 AM, Ben  wrote:
> Hi,
>
> I'm trying to build a web application using Racket.  But I don't understand
> continuations yet.  I think the package is capable of writing simple
> applications without continuations.  So
>
> 1. Which part of the web-server package should I stay away from if I don't
> want to use continuations?

The web-server/servlet module

> 2. Why not separate the basic functionalities of handling requests and
> sending responses out from the package?  I think the advanced concepts like
> continuations will scare some beginners like me away.

It is divided in the way you suggest. The only things that require
continuations are the functions in web-server/servlet, all other
functions and modules do not use them.

> 3. I'm actually interested in continuation.  Are there any resources to
> learn about it?

The tutorial discusses them: http://docs.racket-lang.org/continue/index.html

> 4. URLs like 'standalone.rkt;(("k" . "(1 3 49600023)"))' is not pretty in my
> eye. Is it possible to make it "standalone.rkt" if I'm programming in the
> continuation style?

Yes, but the continuation encoding has to be somewhere in the request.
It could be in the URL (the default), it could be in a hidden form
field, in POST data, in an HTTP header, etc. For everything other than
the URL, you need to have special HTML application support to put it
in the right spot.

Jay

> Thanks,
> Ben
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



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

   "Wherefore, be not weary in well-doing,
  for ye are laying the foundation of a great work.
And out of small things proceedeth that which is great."
  - D 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] How to check a place-channel for a message without blocking?

2015-09-01 Thread Charles Hixson
Is there a way to check whether there is a message available to be 
picked up on a place-channel without blocking?


(If there isn't, the only way forwards for me in Racket is via a server. 
possibly a tcp server, though I don't really want the handshake.  
Possibly a Unix Socket Server.  Possibly a zmq library.)


--
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] How to use the web-server package without continuations?

2015-09-01 Thread Ben
Hi,

I'm trying to build a web application using Racket.  But I don't understand
continuations yet.  I think the package is capable of writing simple
applications without continuations.  So

1. Which part of the web-server package should I stay away from if I don't
want to use continuations?

2. Why not separate the basic functionalities of handling requests and
sending responses out from the package?  I think the advanced concepts like
continuations will scare some beginners like me away.

3. I'm actually interested in continuation.  Are there any resources to
learn about it?

4. URLs like 'standalone.rkt;(("k" . "(1 3 49600023)"))' is not pretty in
my eye. Is it possible to make it "standalone.rkt" if I'm programming in
the continuation style?

Thanks,
Ben

-- 
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] Class constracts and equality

2015-09-01 Thread Konrad Hinsen
Hi everyone,

I am trying to add a contract to a class but find that the mere presence
of the contract breaks my code. Here is a minimal example that illustrates
the problem:

--
#lang racket

(define foo%
  (class object%
(inspect #f)
(super-new)
(init-field value)))

(define/contract foo+c%
  (class/c (init [value symbol?]))
  foo%)

(module+ test
  (require rackunit)
  (check-equal? (make-object foo% 'bar)
(make-object foo% 'bar))
  (check-equal? (make-object foo+c% 'bar)
(make-object foo+c% 'bar)))
--

My class foo% declares (inspect #f) to ensure that foo% objects can be
compared using equal?. As the test shows, this works fine. However, as
soon as I add a contract to my class, equality tests fail
systematically.

Am I using class contracts incorrectly? Or is this a bug, or a
feature?  Is there a workaround?

Thanks in advance,
  Konrad

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