[racket-users] Re: Loading foreign libraries on Windows

2019-02-11 Thread Alex Harsanyi
Do you have x64 Racket installed? This is an error that usually comes up 
when a 32 bit application tries to load a 64 bit DLL.

Alex.

On Tuesday, February 12, 2019 at 2:18:55 PM UTC+8, Philip McGrath wrote:
>
> I'm encountering an issue using `ffi-lib` to load a DLL on Windows. The 
> problem appears to be specific to Racket, as I seem to be able to load the 
> same DLL from Python.
>
> Specifically, I'm trying to build platform-specific packages for libgit2. 
> I can build the library and run its test suite successfully, but when I try 
> to load the DLL with `ffi-lib`, using an absolute path to avoid any search 
> issues, it fails with the message "%1 is not a valid Win32 application.; 
> errid=193". The AppVeyor build log is here 
> ,
>  
> and this is the Racket script 
> 
>  
> that fails to load the DLL. As I mentioned, I can load the DLL successfully 
> with this Python script 
> 
> .
>
> I'm not much of a Windows person, and I'm not sure what else to do to 
> debug this.
>
> -Philip
>

-- 
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] Loading foreign libraries on Windows

2019-02-11 Thread Philip McGrath
I'm encountering an issue using `ffi-lib` to load a DLL on Windows. The
problem appears to be specific to Racket, as I seem to be able to load the
same DLL from Python.

Specifically, I'm trying to build platform-specific packages for libgit2. I
can build the library and run its test suite successfully, but when I try
to load the DLL with `ffi-lib`, using an absolute path to avoid any search
issues, it fails with the message "%1 is not a valid Win32 application.;
errid=193". The AppVeyor build log is here
,
and this is the Racket script

that fails to load the DLL. As I mentioned, I can load the DLL successfully
with this Python script

.

I'm not much of a Windows person, and I'm not sure what else to do to debug
this.

-Philip

-- 
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] Python's append vs Racket's append and helping novices understand the implications

2019-02-11 Thread 韋嘉誠
For anyone creating such a web page for Python to Racket specifically,
there is probably a great deal of inspiration, and reminders of
stumbling blocks, to be found in Arne Babenhauserheide's
https://www.draketo.de/py2guile book (available online for free) about
going from Python to Guile Scheme.

-- 
   /c

On Sun, Feb 3, 2019 at 7:00 AM Matthias Felleisen
 wrote:
> Racket needs *you*. Please.
>
> The proper approach is to have short pages for different language immigration 
> groups: Python and R come to mind as obvious examples but I am sure there are 
> others.
>
> What I mean is we need help and *you* can help. Let me explain it with the 
> Python example:
>
> 1. Set up a page (wiki?) called “From Python to Racket”
>
> 2. Create two sections that are immediately visible from the top:
>
> — idioms
> — performance pitfalls
>
> 3. In the specific case of Python, the second subsection needs to start with 
> a subsection on
>
> — Python Lists aren’t Racket Lists
> — then point to data/ralis and show how to transliterate the 
> loop/append example like this
> — optionally also show the more native Racket idiom
>
> 4. When anyone observers another blog/social media/whatever post on Racket is 
> slow because I come from Python,
>
> (a) point the posters to the page  or
> (b) if it is a new case, write a section for this example then do (a)
>
>
> If you want to help advertise Racket to others, this is an excellent way of 
> helping out.
>
> Thanks — Matthias
>
> [[ p.s. For my very first Python program (a couple of days before meeting 
> with GvR), I used Python’s append and was annoyed beyond belief. ]]
>
>
> --
> 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] Wishlist for regexen: x mode, named captures, embeddable regexn

2019-02-11 Thread Philip McGrath
On Mon, Feb 11, 2019 at 2:32 PM David Storrs  wrote:

> It would be great if Perl's / pcre's "x" mode could be pulled into
> Racket, ideally with modifiers on the end of the regexp instead of
> inside it.  This mode specifies that all whitespace in the pattern
> should be ignored, so if you want to actually match whitespace then
> you need to specify it.  Example:
>
> ; tokenizer code running under the at-exp sublanguage: match a word
> boundary, 'var', whitespace, one or more contiguous word characters
> (ASCII alphanumerics or _), and then another word boundary
>
> @pregexp{\b var \s+ \w+ \b}x
>

Would this do what you want?

#lang at-exp racket

(define (pregexp-x . args)
  (pregexp
   (regexp-replace* #px"\\s+" (string-append* args) "")))

@pregexp-x{\b var \s+ \w+ \b} ;; -> #px"\\bvar\\s+\\w+\\b"

(With an easy optimization being to make `pregexp-x` a macro so that it can
do that work at compile-time when all of the args are string literals.)

Oh, and if I'm already asking for the moon, does Racket have any
> equivalent to Perl's named captures or composable regexen, or any
> possibility of adding them?
>
> (regexp-match @px{\b(?hi|hello)} "hi bob")
> (println greet) ; prints "hi"
>
>
I think both of these could be implemented well in "user space."

You can already compose regular expressions in (byte-)string form.
Functions like `regexp-match` implicitly convert string patterns with
`regexp` (IIRC this predates regexp literals in Racket), and the docs
promise that `object-name` on a regexp value (using either syntax) will
return its source in string form. (That part I didn't realize until just
now.) So, your example:

> (define bar #px"(bar)")
> (regexp-match @px{(foo)@bar} "foobar") ; equivalent to
> @px{(foo)(bar)}. returns '("foobar" "foo" "bar")

could be written as:
#lang at-exp racket

(define (px . args)
  (pregexp (string-append*
(for/list ([x (in-list args)])
  (if (string? x) x (object-name x))

(define bar #px"(bar)")

(regexp-match @px{(foo)@bar} "foobar")
;; -> '("foobar" "foo" "bar")

The named captures are more interesting, because it uses the regexp pattern
as a binding form. There are various balances you could string between
static and dynamic, but what struck me is that it's essentially the same
problem addressed by `web-server/formlets
` (and the original
paper on Links/OCaml, "The Essence of Form Abstraction").

A formlet combines:

   - an HTML fragment than produces N inputs, and
   - a function that consumes N inputs and does some processing

into a composable representation. The library provides some syntactic sugar
to make this nice to write and driver functions like `send/formlet`, which
takes a formlet, sends its HTML to the user.

In your case, you want to associate a regexp that produces N captures with
a function that consumes N inputs. The interesting part is implementing the
syntactic sugar, and the tedious part is implementing `cross` (the
operation to combine formlets—formlets are applicative functors/idioms),
but here's a sketch of how "pregexp formlets" might work at a low-level:
#lang racket

(struct px-formlet (px process i) #:transparent)

(define greet-formlet
  (px-formlet #px"\\b(hi|hello)"
  (λ (greet)
(println greet))
  1))

(define (px-formlet-match f input)
  (match-define (px-formlet px process i) f)
  (define rslt (regexp-match px input))
  (and rslt
   (unless (= i (length (cdr rslt)))
 ;; your library should make it difficult
 ;; or impossible to get here
 (error 'px-formlet-match "wrong number of captures"))
   (apply process (cdr rslt

(px-formlet-match greet-formlet "hi bob")

-Philip

-- 
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] Cannot instantiate `racket/gui/base' a second time in the same process

2019-02-11 Thread Robby Findler
Well, I don't have the cycles to try it myself right now, and I don't
mean to presume on others' time! :)

Robby

On Mon, Feb 11, 2019 at 5:00 PM Stephen Foster  wrote:
>
> Thanks, Robby.  That does make sense.
>
> Meta question: Are you saying that I should attempt this racket/gui 
> refactoring myself?  Or is this something I should expect would happen 
> without my help?
>
> Either is cool.  I just wasn't sure which you were suggesting.
>
>
>
> On Mon, Feb 11, 2019 at 2:46 PM Robby Findler  
> wrote:
>>
>> Probably the best thing would be to adjust racket/gui so that the
>> text% (and perhaps a few smaller other things) was available without
>> racket/gui/base having to be required. I believe that Sam did that to
>> make racket/draw for a reason that was probably like this one.
>>
>> Robby
>>
>>
>> On Mon, Feb 11, 2019 at 4:43 PM Stephen Foster  
>> wrote:
>> >
>> > I've gotten this error many times when building docs.  Some google 
>> > searching gives me the impression that it's a known issue.  Usually, I 
>> > just refactor my code so that racket/gui doesn't get required, and 
>> > everything is fine.  Is there another workaround, though?
>> >
>> > There was some functionality that I'd really like to use in racket:text% 
>> > (for automatically tabifying code snippets).  It works great in all 
>> > contexts except for when I build documentation.
>> >
>> > I suppose I could require racket:text% in a separate process and 
>> > communicate with that process.  I was hoping for something a bit less 
>> > icky, though.
>> >
>> > 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.
>
> --
> Stephen R. Foster, Ph.D., CEO
> stephenfoster.us
> multidimensionalgames.com
> learntomod.com
> vox-l.com
> thoughtstem.com
>
> --
> 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] Cannot instantiate `racket/gui/base' a second time in the same process

2019-02-11 Thread Stephen Foster
Thanks, Robby.  That does make sense.

Meta question: Are you saying that I should attempt this racket/gui
refactoring myself?  Or is this something I should expect would happen
without my help?

Either is cool.  I just wasn't sure which you were suggesting.



On Mon, Feb 11, 2019 at 2:46 PM Robby Findler 
wrote:

> Probably the best thing would be to adjust racket/gui so that the
> text% (and perhaps a few smaller other things) was available without
> racket/gui/base having to be required. I believe that Sam did that to
> make racket/draw for a reason that was probably like this one.
>
> Robby
>
>
> On Mon, Feb 11, 2019 at 4:43 PM Stephen Foster 
> wrote:
> >
> > I've gotten this error many times when building docs.  Some google
> searching gives me the impression that it's a known issue.  Usually, I just
> refactor my code so that racket/gui doesn't get required, and everything is
> fine.  Is there another workaround, though?
> >
> > There was some functionality that I'd really like to use in racket:text%
> (for automatically tabifying code snippets).  It works great in all
> contexts except for when I build documentation.
> >
> > I suppose I could require racket:text% in a separate process and
> communicate with that process.  I was hoping for something a bit less icky,
> though.
> >
> > 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.
>
-- 
Stephen R. Foster, Ph.D., CEO
stephenfoster.us
multidimensionalgames.com
learntomod.com
vox-l.com
thoughtstem.com

-- 
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] Cannot instantiate `racket/gui/base' a second time in the same process

2019-02-11 Thread Robby Findler
Probably the best thing would be to adjust racket/gui so that the
text% (and perhaps a few smaller other things) was available without
racket/gui/base having to be required. I believe that Sam did that to
make racket/draw for a reason that was probably like this one.

Robby


On Mon, Feb 11, 2019 at 4:43 PM Stephen Foster  wrote:
>
> I've gotten this error many times when building docs.  Some google searching 
> gives me the impression that it's a known issue.  Usually, I just refactor my 
> code so that racket/gui doesn't get required, and everything is fine.  Is 
> there another workaround, though?
>
> There was some functionality that I'd really like to use in racket:text% (for 
> automatically tabifying code snippets).  It works great in all contexts 
> except for when I build documentation.
>
> I suppose I could require racket:text% in a separate process and communicate 
> with that process.  I was hoping for something a bit less icky, though.
>
> 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.


[racket-users] Cannot instantiate `racket/gui/base' a second time in the same process

2019-02-11 Thread Stephen Foster
I've gotten this error many times when building docs.  Some google 
searching gives me the impression that it's a known issue.  Usually, I just 
refactor my code so that racket/gui doesn't get required, and everything is 
fine.  Is there another workaround, though?

There was some functionality that I'd really like to use in racket:text% 
(for automatically tabifying code snippets).  It works great in all 
contexts except for when I build documentation.

I suppose I could require racket:text% in a separate process and 
communicate with that process.  I was hoping for something a bit less icky, 
though.

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.


[racket-users] Package not updating after push?

2019-02-11 Thread David Storrs
I've pushed some enhancements to the struct-plus-plus package but the
package server is not picking them up.  I've updated the version
number in info.rkt and I've done "Rescan all my packages" twice.  What
should I do?

-- 
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] Wishlist for regexen: x mode, named captures, embeddable regexn

2019-02-11 Thread David Storrs
There was another thread about regexp-match lately, and it made me
think of a couple things I wish were available

It would be great if Perl's / pcre's "x" mode could be pulled into
Racket, ideally with modifiers on the end of the regexp instead of
inside it.  This mode specifies that all whitespace in the pattern
should be ignored, so if you want to actually match whitespace then
you need to specify it.  Example:

; tokenizer code running under the at-exp sublanguage: match a word
boundary, 'var', whitespace, one or more contiguous word characters
(ASCII alphanumerics or _), and then another word boundary

@pregexp{\b var \s+ \w+ \b}x

Oh, and if I'm already asking for the moon, does Racket have any
equivalent to Perl's named captures or composable regexen, or any
possibility of adding them?

(regexp-match @px{\b(?hi|hello)} "hi bob")
(println greet) ; prints "hi"

(define bar #px"(bar)")
(regexp-match @px{(foo)@bar} "foobar") ; equivalent to
@px{(foo)(bar)}. returns '("foobar" "foo" "bar")

-- 
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] GitHub color for Racket

2019-02-11 Thread Stephen De Gabrielle
It’s a shame ‘rainbow’  isn’t an available colour
S.

On Mon, 11 Feb 2019 at 18:06,  wrote:

> Hi folks,
>
> As some of you may know, GitHub uses a color bar at the top of a
> repository to indicate the languages used. The GitHub color for Racket is
> very dark blue, almost black. Racket's logo uses a lighter, more
> distinctive blue color:
>
> https://racket-lang.org/img/racket-logo.svg
>
> I love Racket, and I think a better GitHub color would make the language
> look more attractive. I've opened a pull request to change the color to be
> similar* to the official logo:
>
> https://github.com/github/linguist/pull/4415
>
> Does anyone have a strong opinion on this? Please feel free to respond to
> me directly, or weigh in on the GitHub pull request, if you don't feel like
> making noise on the mailing list.
>
> Thanks,
> Pavan
>
> *The exact color, #3E5BA9, conflicts with PHP. #3C5CAA is very close, but
> passes GitHub's tests.
>
> --
> 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] GitHub color for Racket

2019-02-11 Thread pavan . maddamsetti
Hi folks,

As some of you may know, GitHub uses a color bar at the top of a repository to 
indicate the languages used. The GitHub color for Racket is very dark blue, 
almost black. Racket's logo uses a lighter, more distinctive blue color:

https://racket-lang.org/img/racket-logo.svg

I love Racket, and I think a better GitHub color would make the language look 
more attractive. I've opened a pull request to change the color to be similar* 
to the official logo:

https://github.com/github/linguist/pull/4415

Does anyone have a strong opinion on this? Please feel free to respond to me 
directly, or weigh in on the GitHub pull request, if you don't feel like making 
noise on the mailing list.

Thanks,
Pavan

*The exact color, #3E5BA9, conflicts with PHP. #3C5CAA is very close, but 
passes GitHub's tests.

-- 
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] Re: nested for loops and suggested alternatives

2019-02-11 Thread Daniel Prager
Hi Travis

Glad you found it instructive.

In mathematical terms these kinds of systems map from the current state at
t=n to the next time-step at t=n+1.

Given a transition function I tend to just use for/list (or for/vector) to
build up a history.

E.g.

#lang racket

(require math/matrix)

(define A (matrix [[0 0 5.905]
   [0.368 0.639 0.025]
   [0.001 0.152 0.051]]))

(define n (col-matrix [5 5 5]))

(define (iterate A n iter)
  (for/list ([i iter])
(define temp n)
(set! n (matrix* A n))
(list i temp)))

(iterate A n 25)


You could use for/fold, which avoids the use of set!, but the syntax is a
little heavier.

Dan

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