Re: [racket-users] Comparing (delimited) continuations in Racket

2015-08-14 Thread Jay McCarthy
This is not a direct answer, but has a few different answer-like things.

The Racket contract system has a similar problem to solve. Suppose
contracted procedure is supposed to return a number? value. The state
would look like this:

( continuation  (obey-or-error number? ( function body )))

Now, suppose that the function ends in a tail-call to a different
procedure that is also expected to return a number?

( continuation  (obey-or-error number? (obey-or-error number?
( function body 

Clearly this pattern can cause the obey-or-error frames to pill up and
consume arbitrary space, despite the fact that all but the inner-most
is unnecessary.

The solution is for the code that inserts the obey-or-error call to
inspect the continuation and tell if it is already going to check some
particular contract. This is like what you need to do: decide if the
continuation is the same, but not on an eq?-basis, but actually on a
deeper more nuanced basis.

This is preciously the featured enabled by continuation marks
(with-continuation-mark and current-continuation-marks). They allow
your code to install information into the stack and then inspect it
later.

If your request for tell if two continuations are the same is about
some such deeper property, then maybe you want to learn about
continuation marks as a more direct way to do it.

You could also hack #%app as you suggest by doing something like:

#lang racket/base
(require racket/list)

(define k-id (gensym 'k-id))
(define-syntax-rule (#%whats-app . e)
  (with-continuation-mark k-id (gensym) (#%app . e)))
(define (continuation-id k)
  (continuation-mark-set-first (continuation-marks k) k-id))
(define (same-continuation? k1 k2)
  (eq? (continuation-id k1)
   (continuation-id k2)))

(define (f x)
  (if (zero? x)
  empty
  (let/cc k
(cons k (#%whats-app f (sub1 x))

(define (snoc l x) (append l (list x)))
(define (g x)
  (define l empty)
  (let loop ([x x])
(unless (zero? x)
  (let/cc k
(set! l (snoc l k))
(loop (sub1 x)
  l)

(module+ test
  (define fl (#%whats-app f 5))
  (same-continuation? (first fl) (second fl))

  (define gl (#%whats-app g 5))
  (same-continuation? (first gl) (second gl)))

Finally, you could also write your program in #lang web-server which
reifies the continuation as a serializable object when you capture it.
These values can be compared with equal? and will do exactly what you
want.

Jay


On Fri, Aug 14, 2015 at 6:40 AM, Klaus Ostermann klaus...@gmail.com wrote:
 Is there any way in Racket to use (delimited) continuations to find out 
 whether I'm evaluating an expression in the same evaluation context as before?

 Let's assume for a second that Racket had an ordinary call stack, and I could 
 access that call stack as a first-order value. Then I could compare two call 
 stacks and find out whether they denote the same evaluation context or not.

 But continuations are of course Racket procedures and eq? always yields #f.

 There is literature on defunctionalizing continuations, which would yield a 
 first-order representation of a continuation, but of course I don't want to 
 defunctionalize by hand, hence I wonder whether there is some way to do this 
 with the batteries that are included in Racket.

 Presumably I could hack something by redefining the application macro, but 
 that's not what I want.

 Any ideas?

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



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

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

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


Re: [racket-users] Comparing (delimited) continuations in Racket

2015-08-14 Thread Klaus Ostermann
Robby, I think what I want is simple to say:

If I have a Racket program and manually CPS-transform and then defunctionalize 
it, I would be able to compare and analyze continuations (and normal 
procedures, for that matter).

I want to be able to do the same without CPS-transforming and defunctionalizing 
by hand, and I was hoping that there is some way to do that in terms of the 
continuation machinery in Racket.

-- 
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] HTTPS connection through proxy (CONNECT HTTP Method)

2015-08-14 Thread Sean Kemplay
On Wednesday, August 12, 2015 at 9:54:23 PM UTC+1, Sean Kemplay wrote:
 On Wednesday, August 12, 2015 at 12:54:10 PM UTC+1, Jay McCarthy wrote:
  On Tue, Aug 11, 2015 at 10:24 AM, Sean Kemplay sean.kemp...@gmail.com 
  wrote:
   Hi All,
  
   Sending an http request through our corporate proxy works as follows for 
   http requests -
  
   (define-values (x y z)
 (http-sendrecv 10.0.0.200 http://www.example.com;
#:port 8080
#:headers '(
Proxy-Authorization: Basic 
   base64encodedcredentials
Proxy-Connections: keep-alive
)
#:ssl? #f
#:method GET))
  
   However fails for HTTPS requests (as expected).
  
   What I need to do is make a request like the above using the #:method 
   CONNECT and then make a secondary request through a returned connection.
  
   Does anyone know how I would go about doing that in Racket?
  
  http-sendrecv combines calls to http-conn-open, http-conn-send!,
  http-conn-recv!, then http-conn-close!. I suspect that you just need
  to break up that one big call into a few calls like open, send, recv,
  send, recv, close. I'd be happy to work on it with you, but I don't
  have such a proxy on hand, so I'll need helping testing it.
  
  Jay
  
  
   Kind regards,
   Sean
  
   --
   You received this message because you are subscribed to the Google Groups 
   Racket Users group.
   To unsubscribe from this group and stop receiving emails from it, send an 
   email to racket-users+unsubscr...@googlegroups.com.
   For more options, visit https://groups.google.com/d/optout.
  
  
  
  -- 
  Jay McCarthy
  http://jeapostrophe.github.io
  
 Wherefore, be not weary in well-doing,
for ye are laying the foundation of a great work.
  And out of small things proceedeth that which is great.
- DC 64:33
 
 Hi Jay,
 
 Thanks for that, yes I think you are right. I have just installed squid at 
 home which also supports http tunnelling. I'll see how I get on and post my 
 results - whether they be good or bad!
 
 It would be really good to at least get an example on the wiki for others to 
 build from, as I suspect a lot of corporate networks are behind proxies and 
 this would be problematic in using Racket to make calls to REST APIs etc 
 which my job at least requires a lot of.
 
 Kind regards,
 Sean

Hi Jay,

Unfortunately I am not getting very far with this.

Our app servers where our production code sits are not behind a proxy, so at 
the end of the day it doesn't rule out using Racket for some of the tasks I 
have in mind. It would be nice to be able to get through the proxy from my 
desktop to test code though.

I tried the following but the connection is ending early -

#lang racket
(require net/http-client)

(define conn (http-conn-open 10.0.0.200 #:port 8080))

(http-conn-send! conn https://news.ycombinator.com/; #:method CONNECT 
#:headers '(Proxy-Authorization: Basic base64encodedcredentials Connection: 
Keep-Alive) #:version #1.1)
(define-values (a b c)(http-conn-recv! conn #:close? #f))
(http-conn-send! conn / #:method GET); #:headers '(Proxy-Authorization: 
Basic Y3hnXHNlYW4ua2VtcGxheTpBdWd1c3QyMDE0 Connection: Keep-Alive) #:version 
#1.1)
(define-values (e f g) (http-conn-recv! conn))
(http-conn-close! conn)

I am basing the above on this S/O post but am not entirely sure if this is even 
the path I should be pursuing!

http://stackoverflow.com/questions/11697943/when-should-one-use-connect-and-get-http-methods-at-http-proxy-server

Here is an example using Node, it opens the connection to the uri through the 
proxy, then writes to that connection through an SSL connection which is 
something I can't see how to do in Racket.

http://blog.vanamco.com/proxy-requests-in-node-js/

I will keep digging, if you have any Ideas or anything I could test against our 
network it would be much appreciated. 

Kind regards,
Sean

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


[racket-users] Re: FrTime basics

2015-08-14 Thread Aidan Gauland
On 13/08/15 22:55, Aidan Gauland wrote:
 Are there any non-graphical FrTime demos?  I'm trying to figure out how
 to define your own behaviors, and just going by the manual
 http://docs.racket-lang.org/frtime/, it seems rather imperative in
 nature, which is not what I understood it to be from reading the
 whitepaper.
 https://cs.brown.edu/people/sk/Publications/Papers/Published/ck-frtime/paper.pdf
 [snip]

Something seemed to click in my head last night after my original post,
and it occurred to me to try this (in DrRacket).

Welcome to DrRacket, version 6.2 [3m].
Language: FrTime; memory limit: 128 MB.
 (define rx (event-receiver))
 (define foo (+ 3 (hold rx)))
 foo
undefined
 (send-event rx 5)
;; The undefined magically changes to 8.


So I think I've got it now.  I suspect I'll have to pick Greg Cooper's
brain about FrTime's innards and undocumented public procedures, once
I've been using it (the documented part of it, anyway) for a while.

--Aidan

-- 
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] Website Eyecandy from days gone by

2015-08-14 Thread Tim Brown
Thanks Eli.

On 13/08/15 18:30, Eli Barzilay wrote:
 On Mon, Aug 10, 2015 at 5:35 AM, Tim Brown tim.br...@cityc.co.uk wrote:
 Folks,

 The “PLT Scheme” website, as was, had a set of preview pictures along
 the left hand side which scrolled in a “fish-eyed” kind of way (you
 either know what I’m talking about or not).

 Is the source of this (or anything similar) available anywhere for me
 to “learn” from?
 
 You can still see it on the old website:
 
 http://plt-scheme.org/screenshots/
 
 (just dismiss the nag message with the close button).  There's a
 possibly slightly newer version on my pages, eg
 
 http://barzilay.org/random/reflection2.html
 
 In both cases, you can just look at the source to see the JS code.
 IIRC, it should just be inlined on the page.
 
 (And apply the usual disclaimers about old JS code that was fighting
 browser problems, many of which are probably dead.)
 


-- 
Tim Brown CEng MBCS tim.br...@cityc.co.uk

City Computing Limited · www.cityc.co.uk
  City House · Sutton Park Rd · Sutton · Surrey · SM1 2AE · GB
T:+44 20 8770 2110 · F:+44 20 8770 2130

City Computing Limited registered in London No:1767817.
Registered Office: City House, Sutton Park Road, Sutton, Surrey, SM1 2AE
VAT No: GB 918 4680 96

-- 
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] HTTPS connection through proxy (CONNECT HTTP Method)

2015-08-14 Thread Sean Kemplay
On Friday, August 14, 2015 at 10:22:03 AM UTC+1, Sean Kemplay wrote:
 On Wednesday, August 12, 2015 at 9:54:23 PM UTC+1, Sean Kemplay wrote:
  On Wednesday, August 12, 2015 at 12:54:10 PM UTC+1, Jay McCarthy wrote:
   On Tue, Aug 11, 2015 at 10:24 AM, Sean Kemplay sean.kemp...@gmail.com 
   wrote:
Hi All,
   
Sending an http request through our corporate proxy works as follows 
for http requests -
   
(define-values (x y z)
  (http-sendrecv 10.0.0.200 http://www.example.com;
 #:port 8080
 #:headers '(
 Proxy-Authorization: Basic 
base64encodedcredentials
 Proxy-Connections: keep-alive
 )
 #:ssl? #f
 #:method GET))
   
However fails for HTTPS requests (as expected).
   
What I need to do is make a request like the above using the #:method 
CONNECT and then make a secondary request through a returned 
connection.
   
Does anyone know how I would go about doing that in Racket?
   
   http-sendrecv combines calls to http-conn-open, http-conn-send!,
   http-conn-recv!, then http-conn-close!. I suspect that you just need
   to break up that one big call into a few calls like open, send, recv,
   send, recv, close. I'd be happy to work on it with you, but I don't
   have such a proxy on hand, so I'll need helping testing it.
   
   Jay
   
   
Kind regards,
Sean
   
--
You received this message because you are subscribed to the Google 
Groups Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
   
   
   
   -- 
   Jay McCarthy
   http://jeapostrophe.github.io
   
  Wherefore, be not weary in well-doing,
 for ye are laying the foundation of a great work.
   And out of small things proceedeth that which is great.
 - DC 64:33
  
  Hi Jay,
  
  Thanks for that, yes I think you are right. I have just installed squid at 
  home which also supports http tunnelling. I'll see how I get on and post my 
  results - whether they be good or bad!
  
  It would be really good to at least get an example on the wiki for others 
  to build from, as I suspect a lot of corporate networks are behind proxies 
  and this would be problematic in using Racket to make calls to REST APIs 
  etc which my job at least requires a lot of.
  
  Kind regards,
  Sean
 
 Hi Jay,
 
 Unfortunately I am not getting very far with this.
 
 Our app servers where our production code sits are not behind a proxy, so at 
 the end of the day it doesn't rule out using Racket for some of the tasks I 
 have in mind. It would be nice to be able to get through the proxy from my 
 desktop to test code though.
 
 I tried the following but the connection is ending early -
 
 #lang racket
 (require net/http-client)
 
 (define conn (http-conn-open 10.0.0.200 #:port 8080))
 
 (http-conn-send! conn https://news.ycombinator.com/; #:method CONNECT 
 #:headers '(Proxy-Authorization: Basic base64encodedcredentials 
 Connection: Keep-Alive) #:version #1.1)
 (define-values (a b c)(http-conn-recv! conn #:close? #f))
 (http-conn-send! conn / #:method GET); #:headers '(Proxy-Authorization: 
 Basic Y3hnXHNlYW4ua2VtcGxheTpBdWd1c3QyMDE0 Connection: Keep-Alive) 
 #:version #1.1)
 (define-values (e f g) (http-conn-recv! conn))
 (http-conn-close! conn)
 
 I am basing the above on this S/O post but am not entirely sure if this is 
 even the path I should be pursuing!
 
 http://stackoverflow.com/questions/11697943/when-should-one-use-connect-and-get-http-methods-at-http-proxy-server
 
 Here is an example using Node, it opens the connection to the uri through the 
 proxy, then writes to that connection through an SSL connection which is 
 something I can't see how to do in Racket.
 
 http://blog.vanamco.com/proxy-requests-in-node-js/
 
 I will keep digging, if you have any Ideas or anything I could test against 
 our network it would be much appreciated. 
 
 Kind regards,
 Sean

Just an update on this, looking at the code for http-client I now understand 
that http-conn is a struct with an input and output port from a tcp connection.

Based on the node.js example I am thinking of instead of calling 
http-conn-send! a second time with a different method I need to write a 
function along the lines of http-conn-tunnel! which somehow pipes ssl input and 
output ports from the tcp input and output ports from http-conn's input and 
output pipes.

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

Re: [racket-users] Comparing (delimited) continuations in Racket

2015-08-14 Thread Vincent St-Amour
On Fri, 14 Aug 2015 07:29:37 -0500,
Robby Findler wrote:
 
 For that you would have to write a (straightforward) compiler that
 transformed a fully expanded Racket program into another program (in
 that same language), inserting with-continuation-mark expressions
 around every subexpression. Run the transformed program. Then, at the
 point that you wish to compare with another, you can get the marks and
 compare them with another set you got earlier. This won't be a short
 function (as Racket is not a toy language), but it will be a
 straightforward one; you do not need to cps-convert or
 defunctionalize.
 
 We have few transformations along these lines implemented already that
 you may wish to look at. The most commonly used one is errortrace and
 it is what we use to get the precise stacktraces that DrRacket shows
 you. A similar transformation is used to do test coverage and another
 to get profiling information. The library is called errortrace and
 that search key in the docs should provide you with more information.

To expand a little on that, I think you should be able to reuse
errortrace out of the box (e.g., by running your code with `racket -l
errortrace my-file.rkt`), and looking up the continuation marks with key
`errortrace-key` (from `errortrace/errortrace-key`).

Errortrace is usable both as a standalone annotator (as in the
instructions above), and as a library. The former is easier to use, and
it sounds like it may be enough for your purposes.

Vincent

-- 
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] Comparing (delimited) continuations in Racket

2015-08-14 Thread Robby Findler
 (1) how grey is your cat?

The color of a television, tuned to a dead channel.

Robby

-- 
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] Comparing (delimited) continuations in Racket

2015-08-14 Thread Tony Garnock-Jones
On 08/14/2015 11:16 AM, Robby Findler wrote:
 The color of a television, tuned to a dead channel.

Bright, pure, sky blue? What an unusual grey.

https://twitter.com/DJSundog/status/629659761902948352

-- 
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] HTTPS connection through proxy (CONNECT HTTP Method)

2015-08-14 Thread Sean Kemplay
On Friday, August 14, 2015 at 3:41:04 PM UTC+1, Sean Kemplay wrote:
 On Friday, August 14, 2015 at 10:22:03 AM UTC+1, Sean Kemplay wrote:
  On Wednesday, August 12, 2015 at 9:54:23 PM UTC+1, Sean Kemplay wrote:
   On Wednesday, August 12, 2015 at 12:54:10 PM UTC+1, Jay McCarthy wrote:
On Tue, Aug 11, 2015 at 10:24 AM, Sean Kemplay sean.kemp...@gmail.com 
wrote:
 Hi All,

 Sending an http request through our corporate proxy works as follows 
 for http requests -

 (define-values (x y z)
   (http-sendrecv 10.0.0.200 http://www.example.com;
  #:port 8080
  #:headers '(
  Proxy-Authorization: Basic 
 base64encodedcredentials
  Proxy-Connections: 
 keep-alive
  )
  #:ssl? #f
  #:method GET))

 However fails for HTTPS requests (as expected).

 What I need to do is make a request like the above using the #:method 
 CONNECT and then make a secondary request through a returned 
 connection.

 Does anyone know how I would go about doing that in Racket?

http-sendrecv combines calls to http-conn-open, http-conn-send!,
http-conn-recv!, then http-conn-close!. I suspect that you just need
to break up that one big call into a few calls like open, send, recv,
send, recv, close. I'd be happy to work on it with you, but I don't
have such a proxy on hand, so I'll need helping testing it.

Jay


 Kind regards,
 Sean

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



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

   Wherefore, be not weary in well-doing,
  for ye are laying the foundation of a great work.
And out of small things proceedeth that which is great.
  - DC 64:33
   
   Hi Jay,
   
   Thanks for that, yes I think you are right. I have just installed squid 
   at home which also supports http tunnelling. I'll see how I get on and 
   post my results - whether they be good or bad!
   
   It would be really good to at least get an example on the wiki for others 
   to build from, as I suspect a lot of corporate networks are behind 
   proxies and this would be problematic in using Racket to make calls to 
   REST APIs etc which my job at least requires a lot of.
   
   Kind regards,
   Sean
  
  Hi Jay,
  
  Unfortunately I am not getting very far with this.
  
  Our app servers where our production code sits are not behind a proxy, so 
  at the end of the day it doesn't rule out using Racket for some of the 
  tasks I have in mind. It would be nice to be able to get through the proxy 
  from my desktop to test code though.
  
  I tried the following but the connection is ending early -
  
  #lang racket
  (require net/http-client)
  
  (define conn (http-conn-open 10.0.0.200 #:port 8080))
  
  (http-conn-send! conn https://news.ycombinator.com/; #:method CONNECT 
  #:headers '(Proxy-Authorization: Basic base64encodedcredentials 
  Connection: Keep-Alive) #:version #1.1)
  (define-values (a b c)(http-conn-recv! conn #:close? #f))
  (http-conn-send! conn / #:method GET); #:headers 
  '(Proxy-Authorization: Basic Y3hnXHNlYW4ua2VtcGxheTpBdWd1c3QyMDE0 
  Connection: Keep-Alive) #:version #1.1)
  (define-values (e f g) (http-conn-recv! conn))
  (http-conn-close! conn)
  
  I am basing the above on this S/O post but am not entirely sure if this is 
  even the path I should be pursuing!
  
  http://stackoverflow.com/questions/11697943/when-should-one-use-connect-and-get-http-methods-at-http-proxy-server
  
  Here is an example using Node, it opens the connection to the uri through 
  the proxy, then writes to that connection through an SSL connection which 
  is something I can't see how to do in Racket.
  
  http://blog.vanamco.com/proxy-requests-in-node-js/
  
  I will keep digging, if you have any Ideas or anything I could test against 
  our network it would be much appreciated. 
  
  Kind regards,
  Sean
 
 Just an update on this, looking at the code for http-client I now understand 
 that http-conn is a struct with an input and output port from a tcp 
 connection.
 
 Based on the node.js example I am thinking of instead of calling 
 http-conn-send! a second time with a different method I need to write a 
 function along the lines of http-conn-tunnel! which somehow pipes ssl input 
 and output ports from the tcp input and output ports from http-conn's input 
 and output pipes.

I haven't given up... yet!

I exported http-conn-from and 

[racket-users] Using the draw and plot packages with other languages

2015-08-14 Thread Marduk Bolaños
Dear all,

As everybody knows, Racket's plot library is feature-rich and produces
beautiful output. The draw library is also great for generating
diagrams. I prefer functional-style drawing over LaTeX packages.

What I would like to do is to be able to use these libraries in
Maxima, Julia and other scientific computing environments.

If I understand correctly, the plot package relies on the draw
package, which in turn uses cairo. Since Racket is a compiled
language, I thought that perhaps it would be possible to compile these
packages as shared libraries and then (ideally automatically) generate
bindings for the desired language.

Given that a lot of time and expertise is involved in the development
of the tools used in the scientific computing workflow, I believe that
in order to maximize the profit and minimize the duplication of
effort, such tools should be able to interoperate smoothly.

In my view, the core algorithms should be written once in a compiled
language and then all that should be needed to use them in your 
prefered language is to generate the bindings.

It really bothers me that the current status of scientific software
engineering is such that there are several implementations of plotting
libraries, computer algebra systems, numerical routines libraries,
etc. all doing mostly the same things but differing in the language in
which they are written.

Note that I have nothing against diversity, but it seems to me that
there is too much reinventing the wheel.

I look forward to your comments.

Best,
Marduk

-- 
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] Comparing (delimited) continuations in Racket

2015-08-14 Thread Klaus Ostermann
Is there any way in Racket to use (delimited) continuations to find out whether 
I'm evaluating an expression in the same evaluation context as before?

Let's assume for a second that Racket had an ordinary call stack, and I could 
access that call stack as a first-order value. Then I could compare two call 
stacks and find out whether they denote the same evaluation context or not.

But continuations are of course Racket procedures and eq? always yields #f.

There is literature on defunctionalizing continuations, which would yield a 
first-order representation of a continuation, but of course I don't want to 
defunctionalize by hand, hence I wonder whether there is some way to do this 
with the batteries that are included in Racket.

Presumably I could hack something by redefining the application macro, but 
that's not what I want.

Any ideas?

-- 
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] Comparing (delimited) continuations in Racket

2015-08-14 Thread Éric Tanter
Hi Klaus,

For what it’s worth, AspectScheme, which needs the call stack to express 
control flow related pointcuts, redefines the #%app macro to reify the parts of 
the call stack that you need using continuation marks.

I doubt there is a way other than that one to reify the call stack, but if 
there is, I would really like to know :)

-- Éric

 On Aug 14, 2015, at 7:40 AM, Klaus Ostermann klaus...@gmail.com wrote:
 
 Is there any way in Racket to use (delimited) continuations to find out 
 whether I'm evaluating an expression in the same evaluation context as before?
 
 Let's assume for a second that Racket had an ordinary call stack, and I could 
 access that call stack as a first-order value. Then I could compare two call 
 stacks and find out whether they denote the same evaluation context or not.
 
 But continuations are of course Racket procedures and eq? always yields #f.
 
 There is literature on defunctionalizing continuations, which would yield a 
 first-order representation of a continuation, but of course I don't want to 
 defunctionalize by hand, hence I wonder whether there is some way to do this 
 with the batteries that are included in Racket.
 
 Presumably I could hack something by redefining the application macro, but 
 that's not what I want.
 
 Any ideas?
 
 -- 
 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] Comparing (delimited) continuations in Racket

2015-08-14 Thread Robby Findler
For that you would have to write a (straightforward) compiler that
transformed a fully expanded Racket program into another program (in
that same language), inserting with-continuation-mark expressions
around every subexpression. Run the transformed program. Then, at the
point that you wish to compare with another, you can get the marks and
compare them with another set you got earlier. This won't be a short
function (as Racket is not a toy language), but it will be a
straightforward one; you do not need to cps-convert or
defunctionalize.

We have few transformations along these lines implemented already that
you may wish to look at. The most commonly used one is errortrace and
it is what we use to get the precise stacktraces that DrRacket shows
you. A similar transformation is used to do test coverage and another
to get profiling information. The library is called errortrace and
that search key in the docs should provide you with more information.

hth,
Robby


On Fri, Aug 14, 2015 at 6:02 AM, Klaus Ostermann klaus...@gmail.com wrote:
 Robby, I think what I want is simple to say:

 If I have a Racket program and manually CPS-transform and then 
 defunctionalize it, I would be able to compare and analyze continuations (and 
 normal procedures, for that matter).

 I want to be able to do the same without CPS-transforming and 
 defunctionalizing by hand, and I was hoping that there is some way to do that 
 in terms of the continuation machinery in Racket.

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