Re: [racket-dev] Racket build dependencies

2013-06-09 Thread Carl Eastlund
It looks like get-module-code from syntax/modcode does what I want
internally.  I've submitted a pull request on github in which I've split
out the two extra functions I need using the functionality that exists.  I
"modernized" the Racket style in that file before making the changes --
turning let into define and so forth.  That makes this a fairly big change,
line-by-line; sorry about that, I know it makes reading the diff tougher,
but it made it easier to figure out what I was working with in the file.

Carl Eastlund

On Sun, Jun 9, 2013 at 10:29 AM, Carl Eastlund  wrote:

> I'm trying to make a "raco make"-like command for ACL2 certification of
> Dracula programs.  Given a Racket program written using the Dracula
> language, the command extracts a proof obligation, saves it as a .lisp
> file, and runs ACL2 on it.  There are a couple pieces of the Racket build
> system that I don't know how to get at, in making this process work.
>
> (1) I don't want to recreate the proof obligation files if they are
> up-to-date.  For this I need to get the name of the compiled .zo file for a
> module for comparison.  Is this functionality available somewhere?  I might
> also need the path of the module's source code, but I assume that's what
> resolved-module-path-name gives me.  Right?
>
> (2) I want to respect settings like PLTCOMPILEDROOTS when deciding where
> to save the proof obligation file.  Basically I want to mangle the module's
> source file name the same way as compilation does, except instead of
> _rkt.zo I want to create _rkt.lisp or some such.  Is _this_
> functionality available somewhere?
>
> I think that's all I would need to get started.  Any help would be
> appreciated, thanks.
>
> Carl Eastlund
>
_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] member like assoc

2013-06-09 Thread Asumu Takikawa
On 2013-06-09 21:15:31 -0500, Robby Findler wrote:
>Sorry: I should have been clearer: I would only expect a difference when
>the list is short (so your benchmark 2).

Here're the numbers for that:

  #lang racket/base
  (define lst '(a b c))
  (time
(for ([i (in-range 3000)])
  (member 'b lst)))

  ;;; NEW BRANCH
  $ racket member-benchmark-4.rkt
  cpu time: 1408 real time: 1414 gc time: 0
  $ racket --no-jit member-benchmark-4.rkt
  cpu time: 3724 real time: 3731 gc time: 0

  ;;; MASTER
  $ racket member-benchmark-4.rkt
  cpu time: 1380 real time: 1384 gc time: 0
  $ racket --no-jit member-benchmark-4.rkt
  cpu time: 3616 real time: 3622 gc time: 0

Cheers,
Asumu
_
  Racket Developers list:
  http://lists.racket-lang.org/dev


[racket-dev] member like assoc

2013-06-09 Thread Robby Findler
Sorry: I should have been clearer: I would only expect a difference when
the list is short (so your benchmark 2).

Robby

On Sunday, June 9, 2013, Asumu Takikawa wrote:

> On 2013-06-09 20:51:21 -0500, Robby Findler wrote:
> >Do the times change if you put an 'in-range' in the for loops?
>
> Is this the code change you meant?
>
>   #lang racket/base
>   (require (only-in racket/list range))
>   (define lst (range 1 5000))
>   (time
> (for ([i (in-range 3)])
>   (member 2500 lst)))
>
>   ;;; NEW BRANCH
>   $ racket member-benchmark-3.rkt
>   cpu time: 1756 real time: 1760 gc time: 0
>   $ racket --no-jit member-benchmark-3.rkt
>   cpu time: 1524 real time: 1530 gc time: 0
>
>   ;;; MASTER
>   $ racket member-benchmark-3.rkt
>   cpu time: 1756 real time: 1761 gc time: 0
>   $ racket --no-jit member-benchmark-3.rkt
>   cpu time: 1532 real time: 1535 gc time: 0
>
> Cheers,
> Asumu
>
_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] member like assoc

2013-06-09 Thread Asumu Takikawa
On 2013-06-09 20:51:21 -0500, Robby Findler wrote:
>Do the times change if you put an 'in-range' in the for loops?

Is this the code change you meant?

  #lang racket/base
  (require (only-in racket/list range))
  (define lst (range 1 5000))
  (time
(for ([i (in-range 3)])
  (member 2500 lst)))

  ;;; NEW BRANCH
  $ racket member-benchmark-3.rkt
  cpu time: 1756 real time: 1760 gc time: 0
  $ racket --no-jit member-benchmark-3.rkt
  cpu time: 1524 real time: 1530 gc time: 0

  ;;; MASTER
  $ racket member-benchmark-3.rkt
  cpu time: 1756 real time: 1761 gc time: 0
  $ racket --no-jit member-benchmark-3.rkt
  cpu time: 1532 real time: 1535 gc time: 0

Cheers,
Asumu
_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] member like assoc

2013-06-09 Thread Robby Findler
Do the times change if you put an 'in-range' in the for loops?

On Sunday, June 9, 2013, Asumu Takikawa wrote:

> On 2013-05-31 19:40:52 -0400, Asumu Takikawa wrote:
> > Is it feasible to get `member` to have the same optional argument
> > behavior as `assoc`? That is, to have an equality predicate as the third
> > argument.
>
> I went ahead and implemented this behavior and submitted a pull request:
>   https://github.com/plt/racket/pull/366
>
> To see if the change is "pay as you go", I ran some microbenchmarks to
> see if old-style `member` calls would slow down (see below). There
> doesn't seem to be any significant slow-down AFAICT.
>
> I was surprised that the non-JIT version was faster in the first case
> but much slower in the second microbenchmark though. (note: I had to
> change the C implementation of `member` for the non-JIT path)
>
> I'd appreciate any suggestions on the code.
>
> Cheers,
> Asumu
>
>   ;;; NEW BRANCH
>   $ racket member-benchmark.rkt
>   cpu time: 1748 real time: 1752 gc time: 0
>   $ racket --no-jit member-benchmark.rkt
>   cpu time: 1524 real time: 1526 gc time: 0
>
>   ;;; MASTER
>   $ racket member-benchmark.rkt
>   cpu time: 1712 real time: 1716 gc time: 0
>   $ racket --no-jit member-benchmark.rkt
>   cpu time: 1524 real time: 1528 gc time: 0
>
> The microbenchmark is just this:
>   #lang racket/base
>   (require (only-in racket/list range))
>   (define lst (range 1 5000))
>   (time
> (for ([i 3])
> (member 2500 lst)))
>
> On a slightly different microbenchmark:
>
>   ;;; NEW BRANCH
>   $ racket member-benchmark-2.rkt
>   cpu time: 2396 real time: 2402 gc time: 0
>   $ racket --no-jit member-benchmark-2.rkt
>   cpu time: 7156 real time: 7174 gc time: 0
>
>   ;;; MASTER
>   $ racket member-benchmark-2.rkt
>   cpu time: 2412 real time: 2416 gc time: 0
>   $ racket --no-jit member-benchmark-2.rkt
>   cpu time: 6892 real time: 6911 gc time: 0
>
>   #lang racket/base
>   (define lst '(a b c))
>   (time
> (for ([i 3000])
> (member 'b lst)))
>
> _
>   Racket Developers list:
>   http://lists.racket-lang.org/dev
>
_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] member like assoc

2013-06-09 Thread Asumu Takikawa
On 2013-05-31 19:40:52 -0400, Asumu Takikawa wrote:
> Is it feasible to get `member` to have the same optional argument
> behavior as `assoc`? That is, to have an equality predicate as the third
> argument.

I went ahead and implemented this behavior and submitted a pull request:
  https://github.com/plt/racket/pull/366

To see if the change is "pay as you go", I ran some microbenchmarks to
see if old-style `member` calls would slow down (see below). There
doesn't seem to be any significant slow-down AFAICT.

I was surprised that the non-JIT version was faster in the first case
but much slower in the second microbenchmark though. (note: I had to
change the C implementation of `member` for the non-JIT path)

I'd appreciate any suggestions on the code.

Cheers,
Asumu

  ;;; NEW BRANCH
  $ racket member-benchmark.rkt
  cpu time: 1748 real time: 1752 gc time: 0
  $ racket --no-jit member-benchmark.rkt
  cpu time: 1524 real time: 1526 gc time: 0

  ;;; MASTER
  $ racket member-benchmark.rkt
  cpu time: 1712 real time: 1716 gc time: 0
  $ racket --no-jit member-benchmark.rkt
  cpu time: 1524 real time: 1528 gc time: 0

The microbenchmark is just this:
  #lang racket/base
  (require (only-in racket/list range))
  (define lst (range 1 5000))
  (time
(for ([i 3])
(member 2500 lst)))

On a slightly different microbenchmark:

  ;;; NEW BRANCH
  $ racket member-benchmark-2.rkt
  cpu time: 2396 real time: 2402 gc time: 0
  $ racket --no-jit member-benchmark-2.rkt
  cpu time: 7156 real time: 7174 gc time: 0

  ;;; MASTER
  $ racket member-benchmark-2.rkt
  cpu time: 2412 real time: 2416 gc time: 0
  $ racket --no-jit member-benchmark-2.rkt
  cpu time: 6892 real time: 6911 gc time: 0

  #lang racket/base
  (define lst '(a b c))
  (time
(for ([i 3000])
(member 'b lst)))

_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] hex decoding?

2013-06-09 Thread Stephen Chang
There doesn't appear to be a library function for going the reverse
direction but here's one way to write it up:

#lang racket

(define ASCII-ZERO (char->integer #\0))

;; [0-9A-Fa-f] -> Number from 0 to 15
(define (hex-char->number c)
  (if (char-numeric? c)
  (- (char->integer c) ASCII-ZERO)
  (match c
[(or #\a #\A) 10]
[(or #\b #\B) 11]
[(or #\c #\C) 12]
[(or #\d #\D) 13]
[(or #\e #\E) 14]
[(or #\f #\F) 15]
[_ (error 'hex-char->number "invalid hex char: ~a\n" c)])))

(define (hex-string->bytes str) (list->bytes (hex-string->bytelist str)))
(define (hex-string->bytelist str)
  (with-input-from-string
   str
   (thunk
(let loop ()
  (define c1 (read-char))
  (define c2 (read-char))
  (cond [(eof-object? c1) null]
[(eof-object? c2) (list (hex-char->number c1))]
[else (cons (+ (* (hex-char->number c1) 16)
   (hex-char->number c2))
(loop))])

(require file/sha1)
(hex-string->bytes (bytes->hex-string #"turtles"))


Welcome to DrRacket, version 5.3.4.6 [3m].
Language: racket [custom].
#"turtles"
>

On Sun, Jun 9, 2013 at 6:30 PM, David Vanderson
 wrote:
> I'm doing some cryptography exercises that involve a lot of hex
> encoding/decoding.  I see there's a bytes->hex-string function in file/sha1
> and openssl/sha1, but I can't find a decode function.
>
> Is a hex decode function in the distribution?
>
> Thanks,
> Dave
> _
>  Racket Developers list:
>  http://lists.racket-lang.org/dev
_
  Racket Developers list:
  http://lists.racket-lang.org/dev


[racket-dev] hex decoding?

2013-06-09 Thread David Vanderson
I'm doing some cryptography exercises that involve a lot of hex 
encoding/decoding.  I see there's a bytes->hex-string function in 
file/sha1 and openssl/sha1, but I can't find a decode function.


Is a hex decode function in the distribution?

Thanks,
Dave
_
 Racket Developers list:
 http://lists.racket-lang.org/dev


Re: [racket-dev] Project Idea to port Paredit mode to DrRacket.

2013-06-09 Thread Asumu Takikawa
On 2013-06-09 23:25:43 +0530, Mayank Jain wrote:
> While it does autocomplete the closing paren, it does not prevent you from
> breaking the form if I accidentally delete the opening/closing paren.

This is a feature that I like a lot from paredit, because it provides
some level of confidence that I won't have silly mismatched parens.

One improvement over paredit that I'd like to see in a DrRacket port is
to handle #; comments correctly.

For the features of paredit that are already in DrRacket, it'd be nice
if the paredit plugin could just change the keybindings around so that
those of us who are used to emacs+paredit can use it without
re-training (unless this is already the case).

Cheers,
Asumu
_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] Project Idea to port Paredit mode to DrRacket.

2013-06-09 Thread Mayank Jain
Thanks guys for your valuable feedback. I'll go through the links and get
back to you.


On Sun, Jun 9, 2013 at 11:04 PM, Laurent  wrote:

> FWIW, I like the Alt-Arrows keybindings of DrRacket for moving around
> s-exp, but they can probably be improved.
> For example, Alt-Up goes up one level, and Alt-Shift-Up selects from the
> cursor's position to the left paren.
> It would probably be better if it selected the whole surrounding s-exp.
>
>
Thanks. Didn't know that.


> If you haven't seen it yet, you can also activate
> Edit/Racket/Automatically adjust closing parentheses.
> The new behavior of the double-quotes with this is great too (and goes
> slightly beyond paredit, IIUC).
>
>
While it does autocomplete the closing paren, it does not prevent you from
breaking the form if I accidentally delete the opening/closing paren.
Paredit does not allow you to do that. It gives you a very systematic way
of editing your code.

It does feel frustrating at first, but since I've been using it for a year
or so, I find that totally worth learning and porting.
Would love to hear someone's opinion on that in this community.

Thank you all.


> Laurent
>
>
> On Sat, Jun 8, 2013 at 8:36 PM, Mayank Jain  wrote:
>
>> Hi,
>>
>> I am participating in "Lisp in Summer Project"[0]. & Recently I stated
>> doing this course on coursera[1], and I realized that there is no
>> equivalent of paredit[2] mode in DrRacket (atleast I couldn't find anything
>> of that sort).
>>
>> And I was wondering if I could work on porting it. Can anyone guide me
>> into what is possible? What I should be looking at etc?
>>
>> I am a noob in Clojure and have basic familiarity with Emacs.
>> I love paredit[3], and I find that very crucial to using lisp dialects
>> and I found it very hard to work without it in DrRacket.
>> So was wondering about this idea.
>>
>> Any feedback, suggestions, criticism etc would be great.
>>
>> Thanks,
>> Mayank.
>>
>> [0] : http://lispinsummerprojects.org/
>> [1] : https://class.coursera.org/programdesign-001/
>> [2] : https://github.com/emacsmirror/paredit
>> [3] : *http://emacsrocks.com/e14.html*
>>
>> _
>>   Racket Developers list:
>>   http://lists.racket-lang.org/dev
>>
>>
>


-- 
Regards,
Mayank.
_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] Project Idea to port Paredit mode to DrRacket.

2013-06-09 Thread Laurent
FWIW, I like the Alt-Arrows keybindings of DrRacket for moving around
s-exp, but they can probably be improved.
For example, Alt-Up goes up one level, and Alt-Shift-Up selects from the
cursor's position to the left paren.
It would probably be better if it selected the whole surrounding s-exp.

If you haven't seen it yet, you can also activate Edit/Racket/Automatically
adjust closing parentheses.
The new behavior of the double-quotes with this is great too (and goes
slightly beyond paredit, IIUC).

Laurent


On Sat, Jun 8, 2013 at 8:36 PM, Mayank Jain  wrote:

> Hi,
>
> I am participating in "Lisp in Summer Project"[0]. & Recently I stated
> doing this course on coursera[1], and I realized that there is no
> equivalent of paredit[2] mode in DrRacket (atleast I couldn't find anything
> of that sort).
>
> And I was wondering if I could work on porting it. Can anyone guide me
> into what is possible? What I should be looking at etc?
>
> I am a noob in Clojure and have basic familiarity with Emacs.
> I love paredit[3], and I find that very crucial to using lisp dialects and
> I found it very hard to work without it in DrRacket.
> So was wondering about this idea.
>
> Any feedback, suggestions, criticism etc would be great.
>
> Thanks,
> Mayank.
>
> [0] : http://lispinsummerprojects.org/
> [1] : https://class.coursera.org/programdesign-001/
> [2] : https://github.com/emacsmirror/paredit
> [3] : *http://emacsrocks.com/e14.html*
>
> _
>   Racket Developers list:
>   http://lists.racket-lang.org/dev
>
>
_
  Racket Developers list:
  http://lists.racket-lang.org/dev


[racket-dev] Racket build dependencies

2013-06-09 Thread Carl Eastlund
I'm trying to make a "raco make"-like command for ACL2 certification of
Dracula programs.  Given a Racket program written using the Dracula
language, the command extracts a proof obligation, saves it as a .lisp
file, and runs ACL2 on it.  There are a couple pieces of the Racket build
system that I don't know how to get at, in making this process work.

(1) I don't want to recreate the proof obligation files if they are
up-to-date.  For this I need to get the name of the compiled .zo file for a
module for comparison.  Is this functionality available somewhere?  I might
also need the path of the module's source code, but I assume that's what
resolved-module-path-name gives me.  Right?

(2) I want to respect settings like PLTCOMPILEDROOTS when deciding where to
save the proof obligation file.  Basically I want to mangle the module's
source file name the same way as compilation does, except instead of
_rkt.zo I want to create _rkt.lisp or some such.  Is _this_
functionality available somewhere?

I think that's all I would need to get started.  Any help would be
appreciated, thanks.

Carl Eastlund
_
  Racket Developers list:
  http://lists.racket-lang.org/dev