Re: [racket-dev] Racket compiler in Racket

2015-02-18 Thread Gustavo Massaccesi
Ok, thanks. I´ll submit it in a few days.

Gustavo

On Wed, Feb 18, 2015 at 1:13 AM, Leif Andersen l...@leifandersen.net wrote:
 Hello,

 I am working on porting the racket compiler to racket. But it still has a
 bit to go and I have not yet ported the optimizer. So go right ahead.

 Thank you.


 ~Leif Andersen

 On Sun, Feb 15, 2015 at 1:36 PM, Gustavo Massaccesi gust...@oma.org.ar
 wrote:

 There is project to rewrite the Racket compiler in Racket. I'd like to
 know if it has advanced. In particular, if it's still possible to make
 big changes to the C code or it's better to wait and keep the code
 almost frozen.

 I'm planning to do few refactoring an improvements in the optimizer
 functions that handle predicates (for example expr_implies_predicate
 and check_known2_pred). The changes are small enough to be implemented
 in a pair of days (if I find no surprises) but they are big enough to
 be painful to port if the code is already translated.

 Gustavo

 --
 You received this message because you are subscribed to the Google Groups
 Racket Developers group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to racket-dev+unsubscr...@googlegroups.com.
 To post to this group, send email to racket-...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/racket-dev/CAPaha9MMSSNLL-30%2B5bUzKgMb8qERN-%3DEOikEV%2B8ySoHcdzSeQ%40mail.gmail.com.
 For more options, visit https://groups.google.com/d/optout.



-- 
You received this message because you are subscribed to the Google Groups 
Racket Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-dev+unsubscr...@googlegroups.com.
To post to this group, send email to racket-...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-dev/CAPaha9N17sf20SJS%2B3ugjXCYzdqZU_Wrzd8AtPasbg76jvNspw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[racket-dev] Github repo is two commits behind

2015-02-02 Thread Gustavo Massaccesi
* openssl: recognize version 1.0.1j #8265c9 (3 days ago) -- latest
commit in git.racket-lang

* pretty-print: fix for a current inspector that sees through
internals #8d49a9 (3 days ago)

* fix reified-syntax-class-curry (missing role argument) #302986 (3
days ago) -- Latest commit in github

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


[racket-dev] Use unsafe in reverse.rkt ?

2014-05-01 Thread Gustavo Massaccesi
I was reading the alternative implementation of reverse in
http://git.racket-lang.org/plt/blob/HEAD:/racket/collects/racket/private/reverse.rkt
and I thought that the “car” and “cdr” could be replaced by the
“unsafe” versions.

I tried a few changes:

* Use unsafe-car and unsafe-cdr

* Remove the eval-jit-enabled check, because parameters are slow.
(Perhaps it can be checked at compile-time instead of at run-time.)

* Use begin-encourage-inline because map.rkt uses it. (But I think
that begin-encourage-inline is not very useful in reverse.rkt.)

I compared the versions (program at the bottom) The program measure
1 times, the time to do 100 reverses of a 1 list.

fast-reverse  168.32 (modified version)
priv-reverse  169.13 (copy of reverse.rkt)
reverse  168.95 (original version)
values  109.77 (use values instead of reverse)

Average time of n=1 runs, sigma~=15, sigma/sqrt(n)~=0.15

In this test, the new version is 0.4% faster, but if we subtract the
time of the “values” version the improvement is 1%.

If you find this useful, I can look at map.rkt.

Gustavo

;-- fast-reverse.rkt
(module reverse '#%kernel
  (#%require '#%unsafe racket/private/performance-hint)
  (#%provide alt-reverse)

  (begin-encourage-inline

(define-values (alt-reverse)
  (let-values ([(reverse)
(lambda (l)
  (if (list? l)
(void)
(raise-argument-error 'reverse list? l))
  (letrec-values ([(loop)
   (lambda (a l)
 (if (null? l)
   a
   (loop (cons (unsafe-car l)
a) (unsafe-cdr l])
(loop null l)))])
reverse


;--- time-reverse.rkt
#lang racket/base
(require (rename-in private-reverse.rkt (alt-reverse priv-reverse)))
(require (rename-in fast-reverse.rkt (alt-reverse fast-reverse)))

(define-syntax-rule (test-time proc msg)
  (begin
(display (string-append run: msg : ))
(time (begin
(display (for/sum ([k (in-range 100)])
   (length (proc (for/list ([i (in-range 1)]) i)
(display  )))
(display (string-append gc3: msg : 0 ))
(time
 (collect-garbage)
 (collect-garbage)
 (collect-garbage)
 )
))

(collect-garbage)
(collect-garbage)
(collect-garbage)

(for ([z (in-range 1)])
  (test-time values  values   )
  (test-time reverse reverse  )
  (test-time priv-reversepriv-reverse )
  (test-time fast-reversefast-reverse )

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


Re: [racket-dev] Catching the undefined value

2014-04-19 Thread Gustavo Massaccesi
I found another problem with the optimizer and the new undefined behavior.

(letrec ([x (if #t 8 x)]) x) ;==8

I also consider this correct in a strange sense :).

Gustavo


Welcome to Racket v6.0.1.4.
 (letrec ([x x]) x)
x: undefined;
 cannot use before initialization
  context...:
   C:\Program Files\Racket-6.0.1.4\collects\racket\private\misc.rkt:87:7
 (letrec ([x 5]) x)
5
 (letrec ([x (if #t 8 x)]) x)
8
 (letrec ([x (if #f 8 x)]) x)
x: undefined;
 cannot use before initialization
  context...:
   C:\Program Files\Racket-6.0.1.4\collects\racket\private\misc.rkt:87:7



On Wed, Apr 16, 2014 at 10:09 AM, Matthias Felleisen
matth...@ccs.neu.edu wrote:

 Ah, too bad:

 pkgs/racket-pkgs/racket-test/tests/racket/optimize.rktl
 ~~~
 --- OLD/pkgs/racket-pkgs/racket-test/tests/racket/optimize.rktl
 +++ NEW/pkgs/racket-pkgs/racket-test/tests/racket/optimize.rktl
 @@ -3416,5 +3416,16 @@
   (read (open-input-bytes (get-output-bytes o))

 ;; 
 +;; Check that an unsufe opertion's argument is
 +;; not optimized away if it's a use of
 +;; a variable before definition:
 +
 +(err/rt-test (let ()
 +   (unsafe-fx+ x 1)
 +   (define x 3)
 +   x)
 + exn:fail:contract:variable?)
 +
 +;; 


 :-)

 On Apr 16, 2014, at 9:02 AM, Matthias Felleisen matth...@ccs.neu.edu wrote:


 On Apr 15, 2014, at 9:29 PM, Asumu Takikawa as...@ccs.neu.edu wrote:

 On 2014-04-15 18:13:31 -0400, claire alvis wrote:
 The push below includes changes to letrec expressions, internal
 definitions, units, classes, and certain ill-formed shared expressions so
 that they no longer leak the `undefined' value.

 This is great! (especially happy that TR, even with classes, doesn't
 have to worry about #undefined anymore)

 BTW, I found this weird behavior:

 Welcome to Racket v6.0.1.3.
 - (require racket/unsafe/ops)
 - (let () (+ x 3) (define x 3) 5)
 ; x: variable used before its definition [,bt for context]
 - (let () (unsafe-fx+ x 3) (define x 3) 5)
 5


 I consider this correct in a strange sense.

 Interestingly enough,

 (let () (displayln  (unsafe-fx+ x 3)) (define x 3) 5)
 x: variable used before its definition
  context...:
   /Users/matthias/plt/racket/collects/racket/private/misc.rkt:87:7

 which is good too. I don't know how Claire and Matthew did this,
 but it's good :-)
 _
  Racket Developers list:
  http://lists.racket-lang.org/dev

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


Re: [racket-dev] Catching the undefined value

2014-04-19 Thread Gustavo Massaccesi
 (letrec ([x (if #t 8 x)]) x) ;==8

It was a mistake. I thought that the “x: undefined; ...” error was an
expansion-time error, not a run-time error.

(I expected an error, because the x in the else part is “undefined”,
even if it’s never accessed.)

Gustavo


On Sat, Apr 19, 2014 at 1:02 PM, Robby Findler
ro...@eecs.northwestern.edu wrote:
 These seem correct to me. What were you expecting (and why?).

 Robby


 On Saturday, April 19, 2014, Gustavo Massaccesi gust...@oma.org.ar wrote:

 I found another problem with the optimizer and the new undefined behavior.

 (letrec ([x (if #t 8 x)]) x) ;==8

 I also consider this correct in a strange sense :).

 Gustavo


 Welcome to Racket v6.0.1.4.
  (letrec ([x x]) x)
 x: undefined;
  cannot use before initialization
   context...:
C:\Program Files\Racket-6.0.1.4\collects\racket\private\misc.rkt:87:7
  (letrec ([x 5]) x)
 5
  (letrec ([x (if #t 8 x)]) x)
 8
  (letrec ([x (if #f 8 x)]) x)
 x: undefined;
  cannot use before initialization
   context...:
C:\Program Files\Racket-6.0.1.4\collects\racket\private\misc.rkt:87:7
 


 On Wed, Apr 16, 2014 at 10:09 AM, Matthias Felleisen
 matth...@ccs.neu.edu wrote:
 
  Ah, too bad:
 
  pkgs/racket-pkgs/racket-test/tests/racket/optimize.rktl
  ~~~
  --- OLD/pkgs/racket-pkgs/racket-test/tests/racket/optimize.rktl
  +++ NEW/pkgs/racket-pkgs/racket-test/tests/racket/optimize.rktl
  @@ -3416,5 +3416,16 @@
(read (open-input-bytes (get-output-bytes o))
 
  ;; 
  +;; Check that an unsufe opertion's argument is
  +;; not optimized away if it's a use of
  +;; a variable before definition:
  +
  +(err/rt-test (let ()
  +   (unsafe-fx+ x 1)
  +   (define x 3)
  +   x)
  + exn:fail:contract:variable?)
  +
  +;; 
 
 
  :-)
 
  On Apr 16, 2014, at 9:02 AM, Matthias Felleisen matth...@ccs.neu.edu
  wrote:
 
 
  On Apr 15, 2014, at 9:29 PM, Asumu Takikawa as...@ccs.neu.edu wrote:
 
  On 2014-04-15 18:13:31 -0400, claire alvis wrote:
  The push below includes changes to letrec expressions, internal
  definitions, units, classes, and certain ill-formed shared
  expressions so
  that they no longer leak the `undefined' value.
 
  This is great! (especially happy that TR, even with classes, doesn't
  have to worry about #undefined anymore)
 
  BTW, I found this weird behavior:
 
  Welcome to Racket v6.0.1.3.
  - (require racket/unsafe/ops)
  - (let () (+ x 3) (define x 3) 5)
  ; x: variable used before its definition [,bt for context]
  - (let () (unsafe-fx+ x 3) (define x 3) 5)
  5
 
 
  I consider this correct in a strange sense.
 
  Interestingly enough,
 
  (let () (displayln  (unsafe-fx+ x 3)) (define x 3) 5)
  x: variable used before its definition
   context...:
/Users/matthias/plt/racket/collects/racket/private/misc.rkt:87:7
 
  which is good too. I don't know how Claire and Matthew did this,
  but it's good :-)
  _
   Racket Developers list:
   http://lists.racket-lang.org/dev
 
  _
Racket Developers list:
http://lists.racket-lang.org/dev
 _
   Racket Developers list:
   http://lists.racket-lang.org/dev

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


Re: [racket-dev] 5.92 release

2014-01-25 Thread Gustavo Massaccesi
If I understand correctly, 5.92 was going to be a “hidden” release.
But I just opened DrRacket 5.3.6 and got this message: “ Racket v5.92
is now available at http://download.racket-lang.org/ ”

Gustavo


On Tue, Jan 14, 2014 at 2:00 PM, Robby Findler
ro...@eecs.northwestern.edu wrote:
 Dear all: we're experimenting with a slightly different release process for
 6.0. We plan to release version 5.92, taking all the usual steps except that
 we announce it only on the users and dev mailing lists. Then, in a few
 weeks, if everything is smooth, we renumber the release and release it with
 the usual announcements (but without a new version of the testing phase). If
 things don't go so smoothly, we try again with 5.93 after fixing some bugs.

 Sorry for not clueing people in earlier.

 Robby, on behalf of the release managers.


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


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


[racket-dev] Strange definition of dict-count in docs and tests

2014-01-17 Thread Gustavo Massaccesi
Hi!

The documentation about gen:dict
http://docs.racket-lang.org/reference/dicts.html#%28def._%28%28lib._racket%2Fdict..rkt%29._gen~3adict%29%29
says that dict-count accepts one argument. But then it is defined with
a #:default argument:

(define (dict-count dict #:default [x #f])
  (or x
  (length (remove-duplicates (alist-v dict) #:key car

It doesn’t produce an error, but can’t imagine a realistic usecase of
#:default with this definition. I think that the #:default argument
should be dropped.

Gustavo

The same code appears in:

pkgs/racket-pkgs/racket-doc/scribblings/reference/dicts.scrbl
Lines 146-148

pkgs/racket-pkgs/racket-test/tests/generic/alist.rkt
Lines 16-18

pkgs/racket-pkgs/racket-test/tests/generic/struct-form.rkt
Lines 16-18

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


[racket-dev] Missing movable primitives in optimizer

2014-01-05 Thread Gustavo Massaccesi
Hi!

The file [plt] / racket / src / racket / src / optimize.c has a list
of movable primitives in lines 955-961. I think that scheme_mcons_proc
is missing. I read the definition and it’s very similar to
scheme_mcons_proc, so I guess that it should be included in the list.

Another possible inclusion is immutable_box, but
scheme_immutable_box_proc is not defined, so to add this more changes
are necessary.

Gustavo

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


Re: [racket-dev] Recompiling on wrong version for compiled code

2013-09-28 Thread Gustavo Massaccesi
I submitted a similar question a few months ago.
http://lists.racket-lang.org/users/archive/2013-January/056038.html

I was using a redefined current-load/use-compiled to delete the old
files, I'm not sure that the code handles all the cases properly, and
that it doesn't delete any source file.

Robby Findler sugested to use 'raco link' to create a collection with
all my personal files, and after the upgrade use 'raco setup' to
recompile all the files. I'm using this solution/workaround.

Gustavo


On Fri, Sep 20, 2013 at 1:14 PM, Tony Garnock-Jones to...@ccs.neu.edu wrote:
 Hi all,

 Is there some reason the compiler can't either (a) ignore or (b) replace
 the outdated .zos when it comes across a situation like the following?

 compiled/html-utils_rkt.zo::0: read (compiled): wrong version for
 compiled code
 compiled version: 5.90.0.5
 expected version: 5.90.0.9
 context...:
  standard-module-name-resolver
  standard-module-name-resolver
  standard-module-name-resolver

 I just ran into this issue with a webservice I run: I had updated Racket
 but forgotten to blow away the compiled .zos of the webservice, so when
 I restarted the service, it repeatedly failed until I went and deleted
 the .zos by hand.

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


[racket-dev] Style guide: keywords and character conventions

2013-07-16 Thread Gustavo Massaccesi
Hi! I was reading the draft of the style guide in the file
[plt]/pkgs/racket-pkgs/racket-doc/scribblings/style/textual.scrbl
(link: 
http://git.racket-lang.org/plt/blob/b2ebb0a28bf8136e75cd98316c22fe54c30eacb2:/pkgs/racket-pkgs/racket-doc/scribblings/style/textual.scrbl
)

In the lines 388 - 348, there is a list of special characters that
mark by convention special kind of symbols. In my opinion, #:
doesn't belong to that list, or at least it needs a special remark.

For example, ? marks predicates, but one? is a normal symbol and
nothing in the language forces or assumes that it's a predicate. In
particular (define one? 5) is a legal Racket instruction, in spite
it is of extremely bad style.

But #: is different. It creates a special kind of data. If I
understand correctly at the kernel level the keyword don't have a
special representation. But at the Racket level there is a reader
extension for #: and write/print/display show the keywords with #: .
And many of the constructs of the language treat the keywords in a
special way, for example lambda, apply, ...

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


Re: [racket-dev] Is anybody else getting this error?

2012-02-21 Thread Gustavo Massaccesi
I saw an error like this a few days ago, but it was in a large
project. This is the minimal example to reproduce the error.

I guest that the problem is that a .zo exist for an older version of a
file that now doesn't compile. The error disappears if I delete all
the .zo files.

I am using the DrRacket version 5.2.1 for Windows.

I filled a bug report with the information:
http://bugs.racket-lang.org/query/?cmd=viewpr=12590

Steps to reproduce the error:

1) Create two directories \dir and \dir\subdir with the files:
;--FILE: dir\def-one.rkt
#lang racket/base
(provide (all-defined-out))
(define (one) 1
#;(define (one) 1) ;duplicated

;--FILE: dir\subsir\one.rkt
#lang racket/base
(require ../def-one.rkt)
(one)

2) Add a compile.ss files to each directory
;--FILE: dir\compile.ss
#lang racket/base
(require compiler/compiler)
(require setup/getinfo)
(compile-directory-zos (current-directory)
   (get-info/full (current-directory)))

;--FILE: dir\subdir\compile.ss
#lang racket/base
(require compiler/compiler)
(require setup/getinfo)
(compile-directory-zos (current-directory)
   (get-info/full (current-directory)))

3) Run the dir\compile.ss to compile and create the .zo files

4) Edit the file dir\def-one.rkt. Remove the #; so the definition of
one is duplicated, and save the file.

5) Run the other dir\subdir\compile.ss to compile and create the .zo
files only in the subdir.

6) Get the ERROR: exception raised by error display handler:
normalize-path: #path:C:/var (within the input path) is not a
directory or does not exist; original exception raised: module:
duplicate definition for identifier

To repeat:

+7) Edit dir\def-one.rkt to make it a valid file. Add again the #; and save

+8) Run dir\compile.ss to compile everithing.

+9) Edit dir\def-one.rkt to make it a invalid. Remove the #; or add
or remove a random ( or ).

+10) Run again dir\subdir\compile.ss to get the error.

 Re: [racket-dev] Is anybody else getting this error?
 Robby Findler
 Tue, 07 Feb 2012 11:11:59 -0800

 Do you get a stacktrace?

 Robby

  On Tue, Feb 7, 2012 at 1:01 PM, Neil Toronto neil.toro...@gmail.com wrote:
  This is from the latest release. On Redex errors and some Typed Racket
  errors (so far), I get something like
 
  exception raised by error display handler: normalize-path:
  #path:/var/tmp/racket (within the input path) is not a directory or does
  not exist; original exception raised: reduction-relation: before underscore
  must be either a non-terminal or a built-in pattern, found 1 in b_1
 
 
  The problem isn't the Redex error I'm getting - I know how to fix that - but
  that it's expecting a /var/tmp/racket directory to exist.
 
  Obviously I could create this directory, but I wanted to bring it up here
  first. It appears that some collects are either making an assumption they
  shouldn't be making, or they rely on a badly behaved function that creates
  temporary files. (I've verified that `make-temporary-file' is working.)
 
  Neil
  _
   Racket Developers list:
   http://lists.racket-lang.org/dev
_
  Racket Developers list:
  http://lists.racket-lang.org/dev