Re: [racket-users] Web server: can't get radio-group formlet to process

2016-02-12 Thread Jay McCarthy
Hi Marc,

You should change

https://github.com/racket/web-server/blob/master/web-server-lib/web-server/formlets/input.rkt#L148

so that if the list is empty, then you return some value that was
passed as an extra keyword to `input-group` and `radio-group`. Can you
check that and see if it works for what you need in your program?

Jay

On Thu, Feb 11, 2016 at 10:27 AM, Marc Kaufmann
 wrote:
> Hi again,
>
> I just realized that I never figured out how to get radio-groups not to
> raise an error when no option is selected. I manage to put defaults for
> input-string and so on, by doing what Jay suggested and redefining my own
> through the use of 'default and 'input.
>
> In the case of radio-group, what I want is to have a default (or #f) value
> when no value has been picked and resend the form for the user to complete
> it. Since there is some magic going on with formlet-process of radio-group
> that I do not understand, I couldn't figure out where to hack it to make it
> accept no values (it blows up trying to call 'first on a list that contains
> no values).
>
> As I mentioned earlier, I can hack this by adding a hidden radio button
> which I check by default, but that is a suboptimal solution.
>
> I'm happy to try and implement something reuseable for other people, if I
> can be pointed at the right part of the code. I followed the code from
> formlet-process to request-bindings/raw to request-bindings/raw promise,
> which apparently is defined (somehow) via
>
> (define-serializable-struct
>   request
>   (method uri headers/raw bindings/raw-promise post-data/raw
>   host-ip host-port client-ip)
>   #:transparent)
>
> I looked at the defining file of define-serializable-struct and gave up.
>
> Thanks,
> Marc
>
> On Mon, Jan 25, 2016 at 2:54 PM, Marc Kaufmann 
> wrote:
>>
>> Done, although since it is my first pull request, let me know if I did it
>> wrong (tried first without forking, which of course was nonsense).
>>
>> I tried to find a way to have the 'id' on radio the same as the 'for' on
>> label, but I couldn't figure out well enough what is going on.
>>
>> Cheers,
>> Marc
>>
>> On Mon, Jan 18, 2016 at 10:50 AM, Jay McCarthy 
>> wrote:
>>>
>>> Great Marc.
>>>
>>> If you want, you could submit a pull-request and we could add the wrap
>>> thing to the main library.
>>>
>>> Jay
>>>
>>> On Wed, Jan 13, 2016 at 5:00 PM, Marc Kaufmann
>>>  wrote:
>>> > So, turns out I can answer my own question, if ugly hacks count.
>>> >
>>> > I copy-pasted (yep, DRY is my guiding principle: Do Repeat Yourself)
>>> > the
>>> > code for radio-group and the functions it depends on and changed the
>>> > part of
>>> > the code that creates the HTML in 'input-group' from
>>> >
>>> >  (for/list ([vn (in-range i)])
>>> >(define e (hash-ref value->element vn))
>>> >(define v (number->string vn))
>>> >(list
>>> > `(input ([name ,name]
>>> >  [type ,kind]
>>> >  [value ,v]
>>> >  ,@(if (checked? e)
>>> >'([checked "true"])
>>> >empty)
>>> >  ,@(attrs e)))
>>> > (display e
>>> >
>>> > to
>>> >
>>> >  (for/list ([vn (in-range i)])
>>> >(define e (hash-ref value->element vn))
>>> >(define v (number->string vn))
>>> >(wrap e (string-append name "-" v)
>>> > `(input ([name ,name]
>>> >  [type ,kind]
>>> >  [value ,v]
>>> >  ,@(if (checked? e)
>>> >'([checked "true"])
>>> >empty)
>>> >  ,@(attrs e))
>>> >
>>> >
>>> > The string-append is hard-coding for the id I want to put on the label
>>> > and
>>> > input (which I am failing to get done right now). It now works when I
>>> > use
>>> > the following definition of radio-group/bootstrap:
>>> >
>>> > (define (wrap/bootstrap e id input)
>>> >   (list
>>> > `(div ((class "form-group"))
>>> > (label ((for ,id))
>>> >,input
>>> >,e
>>> >
>>> > (define (radio-group/bootstrap l
>>> >  #:attributes [attrs (λ (x) empty)]
>>> >  #:checked? [checked? (λ (x) #f)])
>>> >   (input-group/wrap l
>>> >#:kind "radio"
>>> >#:attributes attrs
>>> >#:checked? checked?
>>> >#:wrap wrap/bootstrap))
>>> >
>>> >
>>> > It is not particularly pretty, I do not understand the code in
>>> > 

Re: [racket-users] Licensing Details (Is there a Runtime Library Exception?)

2016-02-12 Thread Asumu Takikawa
On 2016-02-12 09:47:44 -0500, Leif Andersen wrote:
> > If the intention wasn't to force programs written in racket to be open 
> > source, then why wasn't an explicit exemption of the runtime libraries 
> > made, like other projects have? (As stated, like it was done for e.g. GCC 
> > and Java.)
> 
> This is probably because none of us are lawyers. And are thus hesitant
> to write legal documents.

Also making these kind of "crayon licenses" is generally a bad idea:

  
http://opensource.stackexchange.com/questions/1445/how-can-a-crayon-license-be-a-problem

Cheers,
Asumu

-- 
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] Licensing Details (Is there a Runtime Library Exception?)

2016-02-12 Thread Leif Andersen
> yes, I noticed that, but I'm not sure that makes any difference in this case. 
> If code ends up being JITed together with the runtime libraries during 
> execution there's no "easy relinking" possible any more.

So, if you give me the .zo file that you get when you run `raco make`,
I can (at least in theory) take that .zo file and run it against
different implementations of the Racket VM. I think that is what the
page is talking about how it interprets relinking.

> If the intention wasn't to force programs written in racket to be open 
> source, then why wasn't an explicit exemption of the runtime libraries made, 
> like other projects have? (As stated, like it was done for e.g. GCC and Java.)

This is probably because none of us are lawyers. And are thus hesitant
to write legal documents.

> So shipping the executable already trivially satisfies the LGPL then? (At 
> least given racket-lang.org's current interpretation of the LGPL.)

That and the .zo file that you get by running raco make.

Again though, I am not a lawyer. So if you need actual professional
legal advice, please get an actual one.

~Leif Andersen


On Fri, Feb 12, 2016 at 2:08 AM, George Bevan  wrote:
> Thanks for the prompt reply.
>
> Maybe I didn't look close enough - the license page I landed on was this one: 
> http://docs.racket-lang.org/license/index.html
>
> Still,
>
>> This page points out that Racket is released under the LGPL (rather
>> than the GPL)
>
> yes, I noticed that, but I'm not sure that makes any difference in this case. 
> If code ends up being JITed together with the runtime libraries during 
> execution there's no "easy relinking" possible any more.
>
> If the intention wasn't to force programs written in racket to be open 
> source, then why wasn't an explicit exemption of the runtime libraries made, 
> like other projects have? (As stated, like it was done for e.g. GCC and Java.)
>
>
>> Furthermore, this is not revealing any more of your source code than
>> the raco exe format, since the bytecode is embedded in an extractable
>> way in the resulting executable.
>
> So shipping the executable already trivially satisfies the LGPL then? (At 
> least given racket-lang.org's current interpretation of the LGPL.)
>
>
> On Friday, February 12, 2016 at 7:46:45 AM UTC+1, Leif Andersen wrote:
>> You can find the license that Racket is released under here:
>> https://download.racket-lang.org/license.html
>>
>> This page points out that Racket is released under the LGPL (rather
>> than the GPL), and also says:
>>
>> First, if you distribute your Racket application in source form or as
>> compiled bytecode files, the Racket license does not restrict you at
>> all.
>>
>> Second, if you distribute your Racket application as compiled binary
>> generated by raco exe, there are no requirements placed on the
>> licensing of your software. However, the LGPL requires that you make
>> it possible to re-link your software with modified versions of Racket.
>> This means, basically, that you need to provide the compiled bytecode
>> files used to produce the compiled binary, if requested by someone who
>> got your software from you. Note that this does not mean that your
>> software has to be made open source, nor do you have to give the
>> source code to anyone, nor do you have to make the compiled bytecode
>> files available to the public or let other people redistribute them.
>> Furthermore, this is not revealing any more of your source code than
>> the raco exe format, since the bytecode is embedded in an extractable
>> way in the resulting executable.
>>
>> (It also says at the bottom of the page: We are, of course, not
>> lawyers, and this should not be taken as legal advice. However, we
>> wanted to make it clear that Racket is an appropriate building block
>> for all kinds of software, and to clarify how we view the license of
>> Racket.)
>>
>> Hope that helps.
>>
>> ~Leif Andersen
>>
>>
>> On Fri, Feb 12, 2016 at 1:40 AM, George Bevan  wrote:
>> > Do programs written in Racket that use the libraries of racket-lang.org's 
>> > implementation need to be licensed under GPL terms? Much like it is the 
>> > case with e.g. the libraries in AdaCore's Ada implementation?
>> >
>> > Or is there a "Runtime Library Exception" or a "Classpath Exception" or 
>> > similar, like it is the case for GCC or Java/JDK?
>> >
>> > --
>> > 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 

Re: [racket-users] Licensing Details (Is there a Runtime Library Exception?)

2016-02-12 Thread Sam Tobin-Hochstadt
On Fri, Feb 12, 2016 at 9:47 AM, Leif Andersen  wrote:

>> If the intention wasn't to force programs written in racket to be open 
>> source, then why wasn't an explicit exemption of the runtime libraries made, 
>> like other projects have? (As stated, like it was done for e.g. GCC and 
>> Java.)
>
> This is probably because none of us are lawyers. And are thus hesitant
> to write legal documents.

One important thing to note is that Racket re-uses a number of
libraries which are also licensed under the LGPL (such as Lightning,
in the JIT, and pango & cairo, in the GUI), which we do not have the
copyright for and therefore cannot offer exemptions for.

Sam

-- 
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: Call for Google Summer of Code Project Suggestions

2016-02-12 Thread byrondavies
Racket -- including a touch-style GUI -- on Android.

Please!

On Thursday, February 11, 2016 at 1:51:00 PM UTC-7, Leif Andersen wrote:
> Hello All,
> 
> We are in the process of submitting a Google Summer of Code
> application for Racket. If you have an idea for a self contained
> project that would benefit the community, please let us know. These
> should be projects that a student would be able to complete in about 3
> months.
> 
> We will curate a subset of these ideas, and put together a detailed
> list of potential projects for students.
> 
> Here are some example suggestions from Asumu:
>   * Type-based auto-completion
>   * Memory profiler
>   * Video editing DSL (#lang nlve)
>   * Automatically generate typed wrappers from tests or contracts
>   * Improve DrRacket vim plugin
>   * TOTP two-factor auth library for Racket-based websites
>   * Command-line REPL debugger
>   * Pure Racket line editing for XREPL with paren-matching and
> other goodies
>   * RRB-Trees built into the Racket VM as an alternative to immutable
> vectors
> 
> As well as some suggestions we have from previous years:
> https://github.com/racket/racket/wiki/SoC-Ideas-2012
> 
> Thank you.
> 
> ~Leif Andersen

-- 
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] Looking for suggestion on accumulating the paths of Graph from HtDP

2016-02-12 Thread liweijian
在 2016年2月1日星期一 UTC+8上午1:41:51,Matthias Felleisen写道:
> I think you may wish to read How to Design Programs. Here are something that 
> are missing: 
> 
> — data definitions (what’s a graph? what’s a path) 
> — signatures 
> — examples
> — tests 
> 
> Once you supply those missing pieces, you will make much more progress. If 
> you post those, we can also help you make real progress, not just complete a 
> problem from HtDP/2e. 
> 
> 
> > On Jan 30, 2016, at 11:29 PM, liweijian  wrote:
> > 
> > HtDP taught us how to check if there exists path(s) from one node to 
> > another.
> > 
> > I tried to implement accumulating all the paths between two nodes as:
> > 
> > ```racket
> > (define (find-paths origin dest G path)
> >  (cond
> >[(equal? origin dest) (reverse (cons dest path))]
> >[else
> > (find-paths/all (neighbors origin G) dest G (cons origin path))]))
> > 
> > (define (find-paths/all lons dest G path)
> >  (cond
> >[(empty? lons) '(#f)]
> >[else
> > (map (λ (n) (find-paths n dest G path)) lons)]))
> > ```
> > 
> > However, when I tested it by
> > 
> > ```racket
> > (define sample-graph
> >  '((A (B E))
> >(B (E
> > 
> > (define (neighbors origination G)
> >  (cadr (assoc origination G)))
> > 
> > (find-paths 'A 'E sample-graph '())
> > ```
> > 
> > The answer is: '(((A B E)) (A E))
> > 
> > In order to get the right answer, I have to write another `flatten` 
> > function as:
> > 
> > ```racket
> > (define (flatten-path lop)
> >  (cond
> >[(empty? lop) empty]
> >[(not (list? (caar lop))) (cons (first lop) (flatten-path (rest lop)))]
> >[else
> > (append (flatten-path (first lop)) (flatten-path (rest lop)))]))
> > 
> > (filter (λ (path) (not (boolean? (car path (flatten-path (find-paths 'A 
> > 'E sample-graph '(
> > ```
> > 
> > And now it works.
> > 
> > I was wondering if maybe I could improve it? 
> > 
> > -- 
> > 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 
> > For more options, visit https://groups.google.com/d/optout.

Great thanks to Matthias and your great book:)

I found another solution without the nested list problem :
http://stackoverflow.com/questions/26836750/finding-all-paths-in-graph-from-one-node-to-another-node/26847591#26847591


I just added missing parts as follows, it passed all the tests I wrote.

```
#lang racket

(require rackunit)

; Node Node Graph Path -> [Nested List-of Path]
; Find all the paths from orig to dest in G with prefix path
(define (find-paths-aux orig dest G path) 
  (cond 
[(equal? orig dest) (reverse (cons dest path))] 
[else 
 (find-paths/all (neighbors orig G) dest G (cons orig path))])) 

; [List-of Node] Node Graph Path -> [List-of Path]
; Collects all the paths from lons to dest in G with prefix path
(define (find-paths/all lons dest G path) 
  (cond 
[(empty? lons) '(#f)] 
[else 
 (map (λ (n) (find-paths-aux n dest G path)) lons)]))

; A Graph is a [Assoc-List-of [List-of Node]]
; Node is a Symbol
; Path is [List-of Node]
(define sample-graph 
  '((A (B E)) 
(B (E

; Node Graph -> [List-of Node]
; Find all the neighbors of  origination in G
(define (neighbors origination G) 
  (cadr (assoc origination G)))

; Node Node Graph -> [List-of Path]
; Finds all paths from orig to dest in G
(define (find-paths orig dest G)
  (filter (λ (path) (not (boolean? (car path (flatten-path (find-paths-aux 
orig dest G '( )

; Nested List-of Node -> [List-of Path]
; This is the function I want to avoid
(define (flatten-path lop) 
  (cond 
[(empty? lop) empty] 
[(not (list? (caar lop))) (cons (first lop) (flatten-path (rest lop)))] 
[else 
 (append (flatten-path (first lop)) (flatten-path (rest lop)))])) 

(define H0
  '((A (B
(define paths/H0 (find-paths 'A 'B H0))
(check-equal? (length paths/H0) 1)
(check-not-false (member '(A B) paths/H0))

(define H1 
  '((A (B E)) 
(B (E
(define paths/H1 (find-paths 'A 'E H1))
(check-equal? (length paths/H1) 2)
(check-not-false (member '(A E) paths/H1))
(check-not-false (member '(A B E) paths/H1))

(define H2 
  '((A (B C E)) 
(B (E)) 
(C (F))
(E ())
(F (
(define paths/H2 (find-paths 'A 'E H2))
(check-equal? (length paths/H2) 2)
(check-not-false (member '(A E) paths/H2))
(check-not-false (member '(A B E) paths/H2))

(define H3
  '((A (B E))
(B (E F))
(C (D))
(D ())
(E (C F))
(F (D G))
(G (
(define paths/H3 (find-paths 'A 'D H3))
(check-equal? (length paths/H3) 5)
(check-not-false (member '(A E C D) paths/H3))
(check-not-false (member '(A B E C D) paths/H3))
(check-not-false (member '(A E F D) paths/H3))
(check-not-false (member '(A B F D) paths/H3))
(check-not-false (member '(A B E F D) paths/H3))
```

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe 

Re: [racket-users] Standardizing the threading macro and organizing packages

2016-02-12 Thread Brian Adkins
On Sunday, January 31, 2016 at 1:05:17 PM UTC-5, Alexis King wrote:
> > On Jan 29, 2016, at 21:55, Brian Adkins wrote:
> > 
> > Was any consensus reached on this? I've been working through some exercises 
> > in Racket that a friend is implementing in Elixir, and I just came across a 
> > "method chaining" situation. I ended up simply writing a wrapper function, 
> > but using a version of ~> would've been nice.
> 
> Yes, actually, there was. The “threading” package was the result, and
> you can find the documentation here[1]. I believe rackjure’s threading
> implementation now also uses this package, so at least some level of
> standardization has been reached.

Awesome! I just tried it out, and it works great:

(define (score word)
  (apply + (~> word
   string-trim
   string-downcase
   string->list
   (map (curry hash-ref points) _

(define (word-count str)
  (~> str
  string-downcase
  (string-split #px"[^a-z]+")
  (foldl (λ (word hsh) (hash-update hsh word add1 0))
 (make-immutable-hash)
 _)))

> If you want Clojure-style threading macros, the threading package is
> probably your best bet. Of course, that might not actually be what you
> want: consider also looking at the different ~> from the point-free
> package, which is actually a higher-order function. When paired with a
> shorthand function package (which didn’t ever get standardized), it can
> be a little more powerful (and just as concise) than a dumb macro.

I'll check this out later.

-- 
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] Looking for suggestion on accumulating the paths of Graph from HtDP

2016-02-12 Thread Matthias Felleisen

On Feb 12, 2016, at 1:00 PM, liweijian  wrote:

> I just added missing parts as follows, it passed all the tests I wrote.


Great. Use the force Liweijian 

-- 
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] Debug help with Unix Write

2016-02-12 Thread Ty Coghlan
As part of a course I'm in, we had to write a simple bridge simulation that 
could handle data messages to and from unix ports that have attached to them 
several hosts. In addition, these bridges have to implement a simple spanning 
tree algorithm, and send and receive BPDU messages. These messages are all 
formatted in JSON. My partner and I went about designing this in racket, 
changing the port protocol from SOCK_STREAM to SOCK_SEQPACKET (changing the 
binding of the variable from 1 to 5) in the unix library: 
https://github.com/racket/unix-socket. 

We ran into the problem where we were able to read messages from the hosts 
attached to the unix sockets, however, we could not read messages that we had 
sent out (which through the simulation get bounced back to the bridge so we can 
set up the spanning tree). This lead us to believe that there is a bug in how 
we write data to the unix socket, and we spent so long debugging it that we 
eventually just rewrote the program in python to make in before the deadline. 

All outgoing messages are written by a function called broadcast:

(define (broadcast source destination type message port)
  (write-json (hash 'source source 'destination destination
'type type 'message message)
  port))

It takes a string source, destination, message type, message, and finally an 
output port to write them on. Then it just wraps them up in a hash table and 
writes them to the port. We attempted to use display, print, regular write, and 
none of them alleviated the problem. We then looked at everything that passes 
data to broadcast, which includes the bpdu function

(define (bpdu bridge-id root-id cost-to-root lans)
  (for ([lan (hash-values lans)])
(broadcast bridge-id "" "bpdu"
   (jsexpr->string (hash 'id bridge-id 'root root-id 'cost 
cost-to-root))
   (cadr lan

bpdu takes in the current bridge-id, root-id, cost-to-root, and all lans (where 
lans are a three element list of lan id, out-port, and in-port), and simply 
formats them as a string before passing it as the message argument in broadcast 
to every port. This bpdu message is called from our main function, which sets 
up the unix socket connections and continuously loops, sending bpdus every 
500ms. The full (messy) file can be seen at 
https://github.com/cdris/bridges/blob/master/3700bridge.rkt.

Any help would be immensely appreciated. 

-- 
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] Fwd: Us congress hearing of maan alsaan Money laundry قضية الكونغجرس لغسيل الأموال للمليادير معن الصانع

2016-02-12 Thread mona f
YouTube videos of



 U.S. Congress money laundering hearing


of

Saudi Billionaire  " Maan  Al sanea"

 with *bank of America*


and  The  owner of Saad Hospital and  Schools

 in the Eastern Province in *Saudi Arabia*



and the Chairman of the Board of Directors of Awal Bank  in *Bahrain*


With Arabic Subtitles


http://www.youtube.com/watch?v=mIBNnQvhU8s





*موقع اليوتيوب الذي عرض جلسة استماع الكونجرس الأمريكي *

* لمتابعة نشاطات غسل الأموال ونشاطات*



*السعودي معن عبدالواحد الصانع*



*مالك مستشفى  وشركة سعد  ومدارس سعد بالمنطقة الشرقية بالسعودية   ورئيس مجلس
ادارة بنك اوال البحريني*



*مترجم باللغة العربية*



http://www.youtube.com/watch?v=mIBNnQvhU8s





























































-- 
You received this message because you are subscribed to the Google Groups
"Google advanced search" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to google-advanced-search+unsubscr...@googlegroups.com.
To post to this group, send email to google-advanced-sea...@googlegroups.com
.
Visit this group at http://groups.google.com/group/google-advanced-search.
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] Debug help with Unix Write

2016-02-12 Thread Ryan Culpepper
Unix socket ports are block-buffered, so after writing to them you need 
to flush the output. Something like


  (write-json data port)
  (flush-output port)

Your code on github has calls to flush-output without the port argument. 
That doesn't flush the unix socket port; it flushes the current output 
port (usually the console or DrRacket) instead---and those ports are 
line-buffered anyway.


That's my best guess about the problem you saw.

BTW, even after that issue, I would worry about how Racket's IO system 
interacts with SOCK_SEQPACKET sockets. Specifically, I think you might 
lose data if a packet is larger than some internal buffer used by 
Racket. From "man socket":


  SOCK_SEQPACKET sockets employ the same system calls as
  SOCK_STREAM sockets. The only difference is that read(2) calls
  will return only the amount of data requested, and any data
  remaining in the arriving packet will be discarded.

Ryan


On 02/12/2016 01:24 PM, Ty Coghlan wrote:

As part of a course I'm in, we had to write a simple bridge simulation that 
could handle data messages to and from unix ports that have attached to them 
several hosts. In addition, these bridges have to implement a simple spanning 
tree algorithm, and send and receive BPDU messages. These messages are all 
formatted in JSON. My partner and I went about designing this in racket, 
changing the port protocol from SOCK_STREAM to SOCK_SEQPACKET (changing the 
binding of the variable from 1 to 5) in the unix library: 
https://github.com/racket/unix-socket.

We ran into the problem where we were able to read messages from the hosts 
attached to the unix sockets, however, we could not read messages that we had 
sent out (which through the simulation get bounced back to the bridge so we can 
set up the spanning tree). This lead us to believe that there is a bug in how 
we write data to the unix socket, and we spent so long debugging it that we 
eventually just rewrote the program in python to make in before the deadline.

All outgoing messages are written by a function called broadcast:

(define (broadcast source destination type message port)
   (write-json (hash 'source source 'destination destination
 'type type 'message message)
   port))

It takes a string source, destination, message type, message, and finally an 
output port to write them on. Then it just wraps them up in a hash table and 
writes them to the port. We attempted to use display, print, regular write, and 
none of them alleviated the problem. We then looked at everything that passes 
data to broadcast, which includes the bpdu function

(define (bpdu bridge-id root-id cost-to-root lans)
   (for ([lan (hash-values lans)])
 (broadcast bridge-id "" "bpdu"
(jsexpr->string (hash 'id bridge-id 'root root-id 'cost 
cost-to-root))
(cadr lan

bpdu takes in the current bridge-id, root-id, cost-to-root, and all lans (where 
lans are a three element list of lan id, out-port, and in-port), and simply 
formats them as a string before passing it as the message argument in broadcast 
to every port. This bpdu message is called from our main function, which sets 
up the unix socket connections and continuously loops, sending bpdus every 
500ms. The full (messy) file can be seen at 
https://github.com/cdris/bridges/blob/master/3700bridge.rkt.

Any help would be immensely appreciated.



--
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] Quasisyntax bug?

2016-02-12 Thread michael.ballantyne
The expression:

(quasisyntax (quote-syntax quasisyntax))

seems to result in an infinite loop. Does anyone know if that's a bug, or 
expected behavior?

Thanks!

-- 
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] splicing conditional results in the surrounding block?

2016-02-12 Thread Nota Poin
On Thursday, February 11, 2016 at 12:29:04 PM UTC, Neil Van Dyke wrote:
> http://www.neilvandyke.org/racket-html-template/

This does almost exactly what I was thinking about! Looking at the code makes 
me go cross-eyed, but if you (expand-once #'(html-template ...)) enough, it 
turns the SXML tree structure into a linear sequence of (write-bytes) 
statements. It would definitely be possible to instead generate a linear 
sequence of strings, that could be cached and then possibly written with one 
single (write-bytes).

Certainly not worth the trouble, but possible. And very fascinating!

-- 
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] splicing conditional results in the surrounding block?

2016-02-12 Thread Neil Van Dyke

Nota Poin wrote on 02/12/2016 10:41 PM:


This does almost exactly what I was thinking about! Looking at the code makes 
me go cross-eyed,


Yes, I recommend not looking at the code.  IIRC, the code is a little 
icky for a few reasons:
1. It was initially not as clear as I like, just because of the nature 
of how it worked, and because I was figuring it out.
2. We didn't yet have submodules, which are a godsend for working with 
Racket's phases, especially how I prefer to work, with one file per 
package, with inline docs
3. I did a big reworking to facilitate some optimizations for using this 
with the Racket Web Server specifically, which complicated things and 
left a lot of placeholders for further changes.  But then all my 
packages stalled around the time of the new package system work, so it's 
in a half-finished state, and without a cleanup pass (though it should 
work).


Neil V.

--
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] Debug help with Unix Write

2016-02-12 Thread Matthias Felleisen

On Feb 12, 2016, at 1:24 PM, Ty Coghlan  wrote:

> As part of a course I'm in, we had to write a simple bridge simulation that 
> could handle data messages to and from unix ports that have attached to them 
> several hosts. In addition, these bridges have to implement a simple spanning 
> tree algorithm, and send and receive BPDU messages. These messages are all 
> formatted in JSON. My partner and I went about designing this in racket, 
> changing the port protocol from SOCK_STREAM to SOCK_SEQPACKET (changing the 
> binding of the variable from 1 to 5) in the unix library: 
> https://github.com/racket/unix-socket. 
> 
> We ran into the problem where we were able to read messages from the hosts 
> attached to the unix sockets, however, we could not read messages that we had 
> sent out (which through the simulation get bounced back to the bridge so we 
> can set up the spanning tree). This lead us to believe that there is a bug in 
> how we write data to the unix socket, and we spent so long debugging it that 
> we eventually just rewrote the program in python to make in before the 
> deadline. 
> 
> All outgoing messages are written by a function called broadcast:
> 
> (define (broadcast source destination type message port)
>  (write-json (hash 'source source 'destination destination
>'type type 'message message)
>  port))


Consider flushing the output port here. (I just wrote a function like this for 
my class project.) (Also use newline to separate messages.) 


> 
> It takes a string source, destination, message type, message, and finally an 
> output port to write them on. Then it just wraps them up in a hash table and 
> writes them to the port. We attempted to use display, print, regular write, 
> and none of them alleviated the problem. We then looked at everything that 
> passes data to broadcast, which includes the bpdu function
> 
> (define (bpdu bridge-id root-id cost-to-root lans)
>  (for ([lan (hash-values lans)])
>(broadcast bridge-id "" "bpdu"
>   (jsexpr->string (hash 'id bridge-id 'root root-id 'cost 
> cost-to-root))
>   (cadr lan
> 
> bpdu takes in the current bridge-id, root-id, cost-to-root, and all lans 
> (where lans are a three element list of lan id, out-port, and in-port), and 
> simply formats them as a string before passing it as the message argument in 
> broadcast to every port. This bpdu message is called from our main function, 
> which sets up the unix socket connections and continuously loops, sending 
> bpdus every 500ms. The full (messy) file can be seen at 
> https://github.com/cdris/bridges/blob/master/3700bridge.rkt.
> 
> Any help would be immensely appreciated. 
> 
> -- 
> 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] building openwrt .ipk for racket

2016-02-12 Thread Neil Van Dyke
I dumped onto the Web the files I used to build OpenWrt packages for 
Racket: http://www.neilvandyke.org/racket-openwrt/


Neil V.

--
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] splicing conditional results in the surrounding block?

2016-02-12 Thread Nota Poin
On Friday, February 12, 2016 at 1:26:05 AM UTC, Matthew Butterick wrote:
> Of course, you can also use the `at-exp` metalanguage from Scribble to 
> simplify text-heavy constructions like these, with variables interpolated 
> into strings:

> #lang at-exp racket
> 
> (define (query condA condB (limit #f) (offset #f))
>   @~a{SELECT something FROM table WHERE @condA AND @condB @(if limit
>@~a{LIMIT 
> @limit @(if offset
>   
>@~a{OFFSET @offset}
>   
>"")}
>"")})

I could also do this:

(define (query condA condB (limit #f) (offset #f))
  (flatten
(list "SELECT something FROM table WHERE "
condA
" AND "
condB
(if limit
(list "LIMIT " limit
  (if offset
  (list "OFFSET " offset)
  '()))
'(

at-exp really is a fascinating language, but if a (flatten) isn't any more 
computationally expensive, you can just splice all the lists at the end and use 
the regular racket language. Either way would work fine, I suspect.

-- 
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] Quasisyntax bug?

2016-02-12 Thread Alex Knauth
Looks like a bug to me. I also narrowed it down, so that it doesn't need the 
quote-syntax, and I also figured out that it does this before it even expands 
once, so we know it isn't expanding to itself infinitely or anything like that. 
So we know it's a loop within the implementation function itself.

These all loop:
(expand-once #'(quasisyntax (quasisyntax)))
(expand-once #'(quasisyntax (quasisyntax . x)))
(expand-once #'(quasisyntax (x . (quasisyntax . x


> On Feb 12, 2016, at 7:27 PM, michael.ballantyne 
>  wrote:
> 
> The expression:
> 
> (quasisyntax (quote-syntax quasisyntax))
> 
> seems to result in an infinite loop. Does anyone know if that's a bug, or 
> expected behavior?
> 
> Thanks!
> 
> -- 
> 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.