Re: [racket-users] requirements for streaming html parser

2019-06-06 Thread Greg Hendershott
Although I don't think I currently /need/ a streaming parser for speed
or space reasons, I can imagine using one.

I'd suggest making something where the user supplies an "on-element"
"callback", which is called with each element -- plus the "path" of
ancestor elements. The user's callback can do whatever it wants.

That could be its own, focused library. I won't say "simple" because
you're parsing HTML!! :)

I can imagine other libraries built on top of that. One I would want to
use (or write myself, share, and use) would offer something like CSS
selectors. Not their syntax. Just some simple function combinators to
express the equivalent. (Because xml/path is close, and maybe enough for
XML, but not quite enough for real-world HTML.) In fact I already do
this, on the full HTML. I can imagine doing this on top of a streaming
parser, instead.

So those are my quick thoughts. I hope that's helpful, and also, other
people will have even better feedback for you.


p.s. One suggestion I have, which you might not like: I think it would
be good if you host Racket packages on GitHub, GitLab, or similar other
site you find least objectionable. I respect your rationale for not
doing that, to-date. On the other hand, people these days like to see
the full git commit history, issues, and pull requests. It helps them
evaluate a package, and feel good about future availability. When they
don't, it can be a speed bump to adoption. If you're aware of all this
but still don't want to do that, again I 100% respect that. Just my
opinion and perspective.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/87blza17t5.fsf%40greghendershott.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: grammar-based fuzzing

2019-06-06 Thread Robby Findler
In addition to the other suggestions, if you can express the thing you
want to generate as a contract, the contract library will generate
random instances of it. But it doesn't have the tuning of weights
you're looking for.

Robby

On Thu, Jun 6, 2019 at 3:41 PM Eric Eide  wrote:
>
> Ryan Kramer  writes:
>
> > Does Racket have any grammar-based fuzzing utilities?
>
> You might be interested in Xsmith.  Version 1.0 will be released imminently,
> like within the next week.  I'll send another email when it's released.
>
> Stay tuned!
>
> --
> ---
> Eric Eide   . University of Utah School of 
> Computing
> http://www.cs.utah.edu/~eeide/ . +1 (801) 585-5512 voice, +1 (801) 581-5843 
> FAX
>
> --
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/m1a7eucuqa.fsf%40gris.uconnect.utah.edu.
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAL3TdONd_qaEmEOZh%2BchjdRtZ4LdwxwuLZrcBGNRDnCEh49aqw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] requirements for streaming html parser

2019-06-06 Thread Neil Van Dyke
If anyone has a use for a *streaming* permissive HTML parser (i.e., one 
that calls your specific bits of code while it's parsing, rather than it 
constructing some kind of representation of the entire page for your 
code to process afterwards), I'd be interested in what specifically 
you'd like it to do.


(For example, in a simplifying/security Web proxy, in which you want to 
reduce memory requirements on the proxy host, and perhaps also response 
latency, by transforming as you go.  Or in a Web scraper for large query 
results, in which, say, you want to be sending a large amount of 
extracted data to as rows to a different database without buffering up a 
huge page and/or the rows.  Or for scraping a small part of a large page 
without allocating a parsed representation of the entire page.  Or maybe 
you'd like the performance properties of streaming, and the convenience 
of a pattern-based scraper or transformation language atop that.  )


--
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/d2f9c369-31fc-5e8d-1bb4-1751e84c6793%40neilvandyke.org.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: grammar-based fuzzing

2019-06-06 Thread Eric Eide
Ryan Kramer  writes:

> Does Racket have any grammar-based fuzzing utilities?

You might be interested in Xsmith.  Version 1.0 will be released imminently,
like within the next week.  I'll send another email when it's released.

Stay tuned!

-- 
---
Eric Eide   . University of Utah School of Computing
http://www.cs.utah.edu/~eeide/ . +1 (801) 585-5512 voice, +1 (801) 581-5843 FAX

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/m1a7eucuqa.fsf%40gris.uconnect.utah.edu.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] grammar-based fuzzing

2019-06-06 Thread Jay McCarthy
`redex-check` is what you want. If it isn't exactly what you need,
then `data/enumerate` will help you build what you need very easily.

--
Jay McCarthy
Associate Professor @ CS @ UMass Lowell
http://jeapostrophe.github.io
Vincit qui se vincit.

On Thu, Jun 6, 2019 at 3:21 PM Ryan Kramer  wrote:
>
> Does Racket have any grammar-based fuzzing utilities? I'm probably going to 
> play around with this either way, but if there is an existing solution I'll 
> quit after I've had my fun. If, however, people think Racket could use 
> something like this I may attempt to make it into a usable package.
>
> I'm thinking specifically about generating inputs for Quickcheck, but such a 
> fuzzer might have other uses.
>
> For example, given this grammar:
>
> (struct tree (left right) #:transparent)
>
> (define-grammar tree-grammar
>   [Leaf (:choose-integer - )]
>   [Subtree #'(tree Node Node)]
>   [Node #:max-nesting 10
> (:weighted-choice
>  [1 Leaf]
>  [5 Subtree])])
>
> Then (tree-grammar 'Subtree) might generate #'(tree 1 (tree 2 3)) as one of 
> many possibilities.
>
> An important feature that I haven't seen yet is tracking/scoping identifiers. 
> There are times when we want to generate any arbitrary identifier, and other 
> times when we want to use an existing identifier that we know is in scope. 
> For example, if we were fuzzing `let` we might have
>
> (define-grammar let-grammar
>   [Root #'(let ([LetId LetVal]
> ...)
> LetBody)]
>   [LetId (:choose-identifier)]
>   ; TODO ...
>   )
>
> And somehow we want to say that LetBody can and should use the enclosing 
> LetIds, but I don't immediately see a great way to communicate that. It might 
> be possible to have something like (:choose-bound LetId) which would generate 
> a LetId that is known to be in scope.
>
> --
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/832ed76d-33f6-4f3f-b80f-da891613b6a3%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAJYbDakB4emkdCO_noMaB6v_-RQUU1AJS_KBAQYprpkH%2BOCZaw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] grammar-based fuzzing

2019-06-06 Thread Ryan Kramer
Does Racket have any grammar-based fuzzing utilities? I'm probably going to 
play around with this either way, but if there is an existing solution I'll 
quit after I've had my fun. If, however, people think Racket could use 
something like this I may attempt to make it into a usable package.

I'm thinking specifically about generating inputs for Quickcheck, but such 
a fuzzer might have other uses.

For example, given this grammar:

(struct tree (left right) #:transparent)

(define-grammar tree-grammar
  [Leaf (:choose-integer - )]
  [Subtree #'(tree Node Node)]
  [Node #:max-nesting 10
(:weighted-choice
 [1 Leaf]
 [5 Subtree])])

Then (tree-grammar 'Subtree) might generate #'(tree 1 (tree 2 3)) as one of 
many possibilities.

An important feature that I haven't seen yet is tracking/scoping 
identifiers. There are times when we want to generate any arbitrary 
identifier, and other times when we want to use an existing identifier that 
we know is in scope. For example, if we were fuzzing `let` we might have

(define-grammar let-grammar
  [Root #'(let ([LetId LetVal]
...)
LetBody)]
  [LetId (:choose-identifier)]
  ; TODO ...
  )

And somehow we want to say that LetBody can and should use the enclosing 
LetIds, but I don't immediately see a great way to communicate that. It 
might be possible to have something like (:choose-bound LetId) which would 
generate a LetId that is known to be in scope.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/832ed76d-33f6-4f3f-b80f-da891613b6a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Are function parameters copy on write?

2019-06-06 Thread David Storrs
Cool.  Thanks, Jay.

On Thu, Jun 6, 2019 at 12:25 PM Jay McCarthy  wrote:

> On Thu, Jun 6, 2019 at 12:16 PM David Storrs 
> wrote:
>
>>
>>
>> On Thu, Jun 6, 2019 at 12:14 PM Jay McCarthy 
>> wrote:
>>
>>> Your code is passing bytes by value, but bytes are themselves
>>> pointers, so you are passing copies of the pointer, not copies of the
>>> bytes. When you modify it, with `bytes-set!` you are modifying the
>>> underlying structure. When you copy it with `subbytes` or
>>> `bytes-copy`, you are making a new object with a new pointer.
>>>
>>
>> Sweet, that's what I needed to know.  Thank you.
>>
>> What about other things, like arbitrary structs, (im)mutable strings,
>> hashes, etc?
>>
>
> Everything is like this except word sized objects like numbers but those
> are not mutable so you’d never know the difference (performance would be
> same too because the pointer would be word sized anyways.)
>
>
>>
>>
>>> --
>>> Jay McCarthy
>>> Associate Professor @ CS @ UMass Lowell
>>> http://jeapostrophe.github.io
>>> Vincit qui se vincit.
>>>
>>> On Thu, Jun 6, 2019 at 12:00 PM David Storrs 
>>> wrote:
>>> >
>>> > My understanding is that Racket is call by value, not call by
>>> reference.  My application will often be passing around large-ish byte
>>> strings; will they be copied every time I pass them, or will the
>>> interpreter use copy-on-write?
>>> >
>>> > --
>>> > 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.
>>> > To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/racket-users/CAE8gKod0Z%2Bv-3Oew4mPhsT4mwzOLdhc7Q-nF4xf_yH3qAgq_Hg%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 Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to racket-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/CAE8gKodNrutKxDivmbpH7Pz_Y1Hg0BfiavQagVToYdm%2BHsr-%3DQ%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
>
> --
> Jay McCarthy
> Associate Professor @ CS @ UMass Lowell
> http://jeapostrophe.github.io
> Vincit qui se vincit.
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAE8gKocmn7W-GQoeEtrTKy_vN-7c2vfinT8tQ%3DTr0dvYEkM%3DBg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Are function parameters copy on write?

2019-06-06 Thread Jay McCarthy
On Thu, Jun 6, 2019 at 12:16 PM David Storrs  wrote:

>
>
> On Thu, Jun 6, 2019 at 12:14 PM Jay McCarthy 
> wrote:
>
>> Your code is passing bytes by value, but bytes are themselves
>> pointers, so you are passing copies of the pointer, not copies of the
>> bytes. When you modify it, with `bytes-set!` you are modifying the
>> underlying structure. When you copy it with `subbytes` or
>> `bytes-copy`, you are making a new object with a new pointer.
>>
>
> Sweet, that's what I needed to know.  Thank you.
>
> What about other things, like arbitrary structs, (im)mutable strings,
> hashes, etc?
>

Everything is like this except word sized objects like numbers but those
are not mutable so you’d never know the difference (performance would be
same too because the pointer would be word sized anyways.)


>
>
>> --
>> Jay McCarthy
>> Associate Professor @ CS @ UMass Lowell
>> http://jeapostrophe.github.io
>> Vincit qui se vincit.
>>
>> On Thu, Jun 6, 2019 at 12:00 PM David Storrs 
>> wrote:
>> >
>> > My understanding is that Racket is call by value, not call by
>> reference.  My application will often be passing around large-ish byte
>> strings; will they be copied every time I pass them, or will the
>> interpreter use copy-on-write?
>> >
>> > --
>> > 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.
>> > To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/CAE8gKod0Z%2Bv-3Oew4mPhsT4mwzOLdhc7Q-nF4xf_yH3qAgq_Hg%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 Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAE8gKodNrutKxDivmbpH7Pz_Y1Hg0BfiavQagVToYdm%2BHsr-%3DQ%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
-- 

--
Jay McCarthy
Associate Professor @ CS @ UMass Lowell
http://jeapostrophe.github.io
Vincit qui se vincit.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAJYbDa%3DEF0BxMKeGy%2BVCB9iM7Rit-i%3Dy%3DfXFNpQK3Xbw7NKR3g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Are function parameters copy on write?

2019-06-06 Thread David Storrs
On Thu, Jun 6, 2019 at 12:14 PM Jay McCarthy  wrote:

> Your code is passing bytes by value, but bytes are themselves
> pointers, so you are passing copies of the pointer, not copies of the
> bytes. When you modify it, with `bytes-set!` you are modifying the
> underlying structure. When you copy it with `subbytes` or
> `bytes-copy`, you are making a new object with a new pointer.
>

Sweet, that's what I needed to know.  Thank you.

What about other things, like arbitrary structs, (im)mutable strings,
hashes, etc?


> --
> Jay McCarthy
> Associate Professor @ CS @ UMass Lowell
> http://jeapostrophe.github.io
> Vincit qui se vincit.
>
> On Thu, Jun 6, 2019 at 12:00 PM David Storrs 
> wrote:
> >
> > My understanding is that Racket is call by value, not call by
> reference.  My application will often be passing around large-ish byte
> strings; will they be copied every time I pass them, or will the
> interpreter use copy-on-write?
> >
> > --
> > 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.
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAE8gKod0Z%2Bv-3Oew4mPhsT4mwzOLdhc7Q-nF4xf_yH3qAgq_Hg%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 Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAE8gKodNrutKxDivmbpH7Pz_Y1Hg0BfiavQagVToYdm%2BHsr-%3DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Are function parameters copy on write?

2019-06-06 Thread Jay McCarthy
Your code is passing bytes by value, but bytes are themselves
pointers, so you are passing copies of the pointer, not copies of the
bytes. When you modify it, with `bytes-set!` you are modifying the
underlying structure. When you copy it with `subbytes` or
`bytes-copy`, you are making a new object with a new pointer.

--
Jay McCarthy
Associate Professor @ CS @ UMass Lowell
http://jeapostrophe.github.io
Vincit qui se vincit.

On Thu, Jun 6, 2019 at 12:00 PM David Storrs  wrote:
>
> My understanding is that Racket is call by value, not call by reference.  My 
> application will often be passing around large-ish byte strings; will they be 
> copied every time I pass them, or will the interpreter use copy-on-write?
>
> --
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/CAE8gKod0Z%2Bv-3Oew4mPhsT4mwzOLdhc7Q-nF4xf_yH3qAgq_Hg%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 Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAJYbDam4SpLL-vt0q78NpqT_GbxVeLhxkN_UWKB%3DTsKz2zsE%2BA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Are function parameters copy on write?

2019-06-06 Thread Jon Zeppieri
On Thu, Jun 6, 2019 at 12:00 PM David Storrs  wrote:

> My understanding is that Racket is call by value, not call by reference.
> My application will often be passing around large-ish byte strings; will
> they be copied every time I pass them, or will the interpreter use
> copy-on-write?
>


"call-by-value" is used in two very different ways. Racket is call-by-value
in the sense that all arguments to functions need to be evaluated before
the function body is evaluated. This kind of "call-by-value" is
distinguished from other evaluation strategies, like call-by-name or
call-by-need.

The other sense of the term -- and the one you're asking about -- has to do
with whether arguments are copied from caller to callee. I find the terms
"call-by-value" and "call-by-reference" in this context to be pretty
confusing. (If the function argument in question is a mutable byte-string,
why wouldn't passing it "by-value" imply that you pass the very same
mutable byte-string, rather than making a copy of it?) At any rate, Racket
does not copy arguments on function calls (except insofar as the copy is
indistinguishable from the original -- as with a fixnum, for example).

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAKfDxxx8TxKvuASFRgNd8A205LvdEFzggG-BN7o8ocRN5pk%2BvQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Are function parameters copy on write?

2019-06-06 Thread David Storrs
My understanding is that Racket is call by value, not call by reference.
My application will often be passing around large-ish byte strings; will
they be copied every time I pass them, or will the interpreter use
copy-on-write?

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAE8gKod0Z%2Bv-3Oew4mPhsT4mwzOLdhc7Q-nF4xf_yH3qAgq_Hg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] scopes across files

2019-06-06 Thread Fastmail


> On Jun 3, 2019, at 11:52 AM, Eric Griffis  wrote:
> Several times now, I've run into one or another form of the following problem:
> 
> Say I want to build primitives to
> 
> declare an "interface" as a list of names, and
> implement and use those names at run time in a limited scope


The `implement` macro needs to place its identifiers (say, `say`) inside the 
lexical context of the calling site, so that they bind other code coming in 
from the calling site (for instance, `(say 'hello)`). Below, the submodules are 
not essential for the example, but are meant to show that the module (or file) 
boundaries don't affect the result. 

#lang racket

(module interface racket
  (provide interface)
  (define-syntax (interface stx)
(syntax-case stx ()
  [(_ id member-id ...) #'(define-syntax id #'(member-id ...))])))

(module implement racket
  (require (for-syntax racket/syntax))
  (provide implement)
  (define-syntax (implement stx)
(syntax-case stx ()
  [(_ class-id def ... expr)
   (with-syntax ([(id ...) (for/list ([stx (syntax-e (syntax-local-value 
#'class-id))])
 (format-id #'expr "~a" (syntax->datum stx)))])
 #'(letrec ([id def] ...) expr))])))

(require 'interface 'implement)

(interface Speaker say speak)
(implement Speaker displayln (say 'hello) speak)

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/4B458B0A-90EC-4364-B417-516E46E1B39A%40mbtype.com.
For more options, visit https://groups.google.com/d/optout.