Re: [racket-users] How 'Pythonic' Can Racket Be Made?

2023-10-12 Thread Matthias Felleisen


We tried embedding Python into Racket nee PLT Scheme some 20 years ago, twice: 

Here is a paper on the second attempt: 

  From Python to PLT Scheme 
  https://www2.ccs.neu.edu/racket/pubs/#scheme2003-ms

Daniel Silva took the lead on this initiative. The surface language was (back 
then) covered. 
It’s Python runtime system that made it essentially impossible to interop with 
the (even 
then) many C libs. 

-- 
This group is deprecated and retained as an archive. 

Racket discussions have moved to the Racket Discourse at  
https://racket.discourse.group/ .

---
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.
--- 
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/C4A7AF02-5A8B-4BB1-8864-67EC358471D6%40felleisen.org.


Re: [racket-users] Core Team: I need you decide what I should do about the spammer.

2022-01-12 Thread Matthias Felleisen



Thank you Sage for taking on this task. — Matthias


-- 
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/FC8531A1-1D73-47EB-B379-E0138DF143EC%40felleisen.org.


Re: [racket-users] Core Team: I need you decide what I should do about the spammer.

2021-12-18 Thread Matthias Felleisen

+2! And many thanks. (I was personally spared this spam until very recently. No 
clue why) 

— Matthias




> On Dec 18, 2021, at 2:55 PM, Robby Findler  wrote:
> 
> +1! Thank you. 
> 
> Robby
> 
> On Sat, Dec 18, 2021 at 1:43 PM Matthew Flatt  > wrote:
> The "members" option sounds right to me. Thanks for tracking down a way
> to improve the situation!
> 
> At Sat, 18 Dec 2021 19:35:23 +, Sage Gerard wrote:
> > Core team,
> > 
> > Sam asked me to issue bans for a troublesome spammer. I've done so, even
> > just today. I understand I need quorum for larger decisions. This is why
> > I have not yet reconfigured the list to permanently stop the spammer.
> > After researching the problem further, I need your urgent attention.
> > 
> > I found that the spam messages sometimes link to other Google group
> > posts affected by the spammer. A recent trail leads to a
> > comp.lang.python Google message in 2017. I suspect that email addresses
> > are scraped in unmoderated lists that freely hand out membership. After
> > checking the list settings, I found that this is one of those lists. I
> > hypothesize that our email addresses are being scraped and
> > cross-referenced for use in other unmoderated lists.
> > 
> > It's one thing to flatly complain about a spammer on this list, and
> > another to willingly maintain a transmission vector. We need to stop
> > automatically handing out group membership with our current settings. We
> > can have  issue list memberships. I need you all to fill in the
> > blank with "moderators" or "members." I'll translate the settings
> > accordingly.
> > 
> > Given the holidays, I respect your time. Please reciprocate with respect
> > for the urgency this problem creates. I will revoke my own mailing list
> > privileges and membership in three weeks, on January 8th, 2022. I will
> > leave the settings however they read at the time to prevent
> > interruption, and request that own messages then be deleted to limit the
> > role my email address plays for the spammer.
> > 
> > I am not volunteering to moderate membership applications, and I am not
> > commenting on how to verify the impact of possible email leaks. Between
> > the Discourse move and (majority?) perspective towards email, I'm not
> > sure how I would be useful doing either. If my opinion holds weight, I'd
> > advise the answer be "members" so that any available moderators can
> > focus on rule breakers while the community grows at a self-directed speed.
> > 
> > Let me know, and thank you.
> > 
> > 
> > 
> > -- 
> > 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/5fa6a8bb-88e4-37c6-f0b9-2ed372bc
> >  
> > 
> > e8fe%40sagegerard.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 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/20211218124300.343%40sirmail.smtps.cs.utah.edu
>  
> .
> 
> -- 
> 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/CAL3TdOMCXH4Zio1%2B96Nj_Zgj2vByetG-%3D8i93%3DLYjTpaBrw8DA%40mail.gmail.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/649B3011-618B-466E-AE20-B4C13629CA71%40felleisen.org.


Re: [racket-users] The case, and a proposal, for elegant syntax in #lang racket2

2019-07-15 Thread Matthias Felleisen


Jack, 

the word “diversity” is inherently political. It is designed as a wedge, a tool 
to separate people into groups and then from each other. It is used as a kudgel 
by one side of the political spectrum to relentlessly hit the other side. It 
was bad enough to have been told that there were too many “cis-gendered white 
males” at RacketCon. 

My message was not one of __politics__ but of __policy__. (And for the record, 
you have no clue what my political views are or how I deal with the diversity 
of individuals in this community.)  I do not wish to see this mailing list turn 
into another political echo chamber, because then I have to remove myself from 
it and the public Racket community. If people wish to discuss the politics of 
diversity in the Racket community, please create a Facebook group and go there. 

— Matthias







> On Jul 15, 2019, at 1:06 PM, Jack Firth  wrote:
> 
> Matthias, I ask that you please not respond to discussion about the diversity 
> of the Racket community by saying it's a political topic and politics have no 
> place here. That statement alone is political and makes many people feel 
> unwelcome, including me.
> 
> On the topic of a new syntax: I am strongly in favor. I think it will remove 
> barriers to entry that have deterred many potential Racketeers. And if 
> there's one community I trust to put care and thoughtfulness into a surface 
> syntax design, it's the Racket community.
> 
> On Monday, July 15, 2019 at 10:19:16 AM UTC-6, Matthias Felleisen wrote:
> 
> 
> > On Jul 14, 2019, at 1:44 PM, someone wrote: 
> > 
> > - I am indeed very for growth in the community, though my main interest 
> >   in growth is in seeing a wider diversity of participants than just 
> >   raw numbers.  Obviously other peoples' mileage may vary. 
> 
> 
> This is politics and politics has no business whatsoever on this mailing 
> list. I believe there are things such as Facebook, Instagram and other 
> Web-chambers where political opinions are welcome and echoes will always 
> confirm your opinions. 
> 
> ;; - - - 
> 
> Our policy has always been that everyone, absolutely everyone, is welcome on 
> this technical list to discuss technical issues. We don’t exclude anyone. And 
> everyone gets treated the same and gets productive responses if possible. In 
> particular, politics stays off this list; it’s divisive enough in the rest of 
> the world. 
> 
> Thank you — Matthias 
> 
> 
> -- 
> 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/a63d9bdb-4d5d-49e8-9451-d6524ac24752%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/87B3D875-42D4-4951-B08D-96BF28468EF8%40felleisen.org.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] The case, and a proposal, for elegant syntax in #lang racket2

2019-07-15 Thread Matthias Felleisen



> On Jul 14, 2019, at 1:44 PM, someone wrote:
> 
> - I am indeed very for growth in the community, though my main interest
>   in growth is in seeing a wider diversity of participants than just
>   raw numbers.  Obviously other peoples' mileage may vary.


This is politics and politics has no business whatsoever on this mailing list. 
I believe there are things such as Facebook, Instagram and other Web-chambers 
where political opinions are welcome and echoes will always confirm your 
opinions. 

;; - - - 

Our policy has always been that everyone, absolutely everyone, is welcome on 
this technical list to discuss technical issues. We don’t exclude anyone. And 
everyone gets treated the same and gets productive responses if possible. In 
particular, politics stays off this list; it’s divisive enough in the rest of 
the world. 

Thank you — Matthias

-- 
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/B7391FF7-FDE7-42A5-921D-BA9B78B463C9%40felleisen.org.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: Thinking in scheme / racket

2019-07-11 Thread Matthias Felleisen


If I may, let me address the (at least) four dimensions of coding that have 
come up in this thread, as concretely as possible but with some generalizations 
added: 

1. Performance 

Generally speaking, Python is a thin layer over C. It comes with almost all the 
performance advantages of C and all the disadvantages (complete lack of 
safety). 

Specifically, the “naive” Racket code (that was mentioned) allocates many 
intermediate list raising the pressure on memory. As a functional programmer, 
you need to pay attention to allocation (cons, structs, lambda, objects) when 
performance matters. ~~ Haskell performs some “loop fusion” aka “deforestation” 
but the overhead of uniform laziness gets in the way. If you were to ask on a 
Haskell mailing list, you’d be told “sprinkle ! everywhere” (meaning make the 
program as strict as possible). 

The performance of your program also suffers from linking Typed Racket code 
into Racket code in a critical place in the for loop. The for/ version in Typed 
Racket is the best you can do in terms of performance. 

2. What matters about code (systematic design) 

Performance, in many cases. 

But real code is code that survives long enough so that person 2 will open a 
file many weeks/months/years after after person 1 wrote it. (Person 2 could be 
an aged version of person 1.) The performance of person 2 on changing this file 
depends on 

— how systematically person 1 went about his work 
— how well person 1 expressed this systematic procedure 
(— how well person 2 is trained to understand these ideas) 

The goal of HtDP is to get this idea across. One day I’ll write HtD C/S to 
scale this up. 

2a. Functional programming 

… excels at designing systematically code at all scales. There are many 
reasons; here are 3 examples: 

— fp encourages type-driven design in a rich language of types (even if 
the types are informal as in HtDP). 
— fp drives people to match expressions to the type structure (if you 
add a variant it’s easy to find where to add an action) 
— fp makes testing very easy 

If 3 isn’t enough, give me an N and I’ll come up with more. 

2b. Functional programming can be done in almost any language, though some make 
it a bit harder than others. So don’t make judgments across entire languages. 

(Josh Bloch: “Favor Immutability” (item 13) and “Minimize Mutability” 
(item 15) in “Effective Java.” He designed the API.) 

3. Figuring out a good way of writing this Racket program goes as follows for 
experienced Racket/FP programmers: 

FP a la Racket encourages one more way of programming: 

— design systematically 
— then transform systematically 

So in Racket when you see 

(filter … (map …)) 

you know that 
(a) this allocates 
(b) can be transformed into a for/list comprehension that uses #:when 
(by practice) 
(c) (length (for/llist (.. #:when ..) ..)) can be transformed 
into (for/sum … #:when ) 1)


Now in a perfect world, you’d point a performance debugger at this (called 
optimization coach or profler) and it may tell you that calling isprime? from 
the Math library imposes a high cost and that adding types to your code will 
eliminate this “borderline cost” (but not the cost of primality checking). 

— Matthias








-- 
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/76869941-0765-47BC-894D-66488AACA7A8%40felleisen.org.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Contracts in lambda?

2019-07-10 Thread Matthias Felleisen


[(contract (-> string? integer?) (λ (x) x) 'a 'b)
 "hello”]




> On Jul 10, 2019, at 10:11 PM, Kevin Forchione  wrote:
> 
> Hi guys,
> Is there a way to apply contracts to a lambda without associating it with an 
> identifier? What I want is to be able to pass lambda functions around without 
> having to bind them to a symbol. I could use raise-argument-error/ 
> raise-result-error but the contract system is more powerful and  I’m hoping 
> there’s a wrapperI of some sort that will do the trick. Something like:
> 
> (assert-contract [tag] (lambda argspec contract-spec body …)) ;; <= [ta] 
> would just be a symbol for the error message 
> 
> Kevin
> 
> -- 
> 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/B0725B4A-8D61-4F6C-AE31-9A7E067F82AE%40gmail.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/90A0CD6C-1349-4BB7-B51A-9D83E6271CE9%40felleisen.org.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] raise-argument-error missing list?

2019-07-08 Thread Matthias Felleisen


We all are indeed at Racket school. 

The arguments for/against contracts have been made over and over again 
especially by Betrand Meyers, before we even introduced and studied the 
higher-order boundary-tied variant. 

+ Contracts separate the core functionality of a service module from its 
assumptions. 
+ Contracts can be read separately as API specs ~~ no need to read the code of 
a function/class/method. 
+ Contracts are more concise than manual checks and they are collected in a 
single space. 
+ Contract error messages are systematically generated and readable. 
+ An improvement to the contract system automatically benefits all contracts. 

- Contracts might occasionally impose a small performance overhead over manual 
contracts. (They might also be faster if they can communicate with the 
compiler.) 
- Contract boundaries are somewhat “stiff” as Oak says in his email. 
Contributions for boundary re-factorings in DrRacket are welcome. 

Now you need to choose which dis/advantages you prefer — Matthias

-- 
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/A8D728B0-3623-4E85-89DD-66ACE67549CA%40felleisen.org.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] What's wrong with my code?

2019-07-07 Thread Matthias Felleisen

With some for/loops in TR you’re out of luck. The expansion are too complex to 
type-check easily. 


> On Jul 7, 2019, at 10:24 AM, 曹朝  wrote:
> 
> This is a simple algorithm for compute the shortest edit distance, it can 
> work with `#lang racket/base`.
> But in Typed Racket, I just got the error message: "insufficient type 
> information to typecheck". I don't know why this code can't pass the type 
> checker.
> Someone can help? Thank you.
> 
> #lang typed/racket/base
> (require math/array)
> 
> (: shortest-edit-distance (-> String String Integer))
> (define (shortest-edit-distance str0 str1)
> (let* ([l0 : Integer (string-length str0)]
>[l1 : Integer (string-length str1)]
>[table : (Mutable-Array Integer) (array->mutable-array (make-array 
> (vector l0 l1) 0))])
>   (for*/last : Integer ([i0 : Integer (in-range l0)]
> [i1 : Integer (in-range l1)])
> (let* ([c0 : Char (string-ref str0 i0)]
>[c1 : Char (string-ref str1 i1)]
>[base : Integer (cond
>  [(and (= i0 0) (= i1 0)) 0]
>  [(= i0 0) (array-ref table (vector i0 (sub1 
> i1)))]
>  [(= i1 0) (array-ref table (vector (sub1 i0) 
> i1))]
>  [else (min (array-ref table (vector i0 (sub1 
> i1)))
> (array-ref table (vector (sub1 i0) 
> i1))
> (array-ref table (vector (sub1 i0) 
> (sub1 i1])]
>[answer : Integer (if (char=? c0 c1) base (add1 base))])
> 
>   (array-set! table (vector i0 i1) answer)
>   answer
> 
> <截屏2019-07-0800.15.13.png>
> 
> 
> 
> -- 
> 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/1fa2f544-9f60-4e00-a451-b42b1e4f5b0f%40googlegroups.com
>  
> .
> For more options, visit https://groups.google.com/d/optout 
> .
> <截屏2019-07-0800.15.13.png>

-- 
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/19F2258A-7D7B-4A5D-B93B-542CBE374D69%40felleisen.org.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] resources on PL design

2019-07-02 Thread Matthias Felleisen


Stephen, since Neil mentioned Alan Kay’s highly informative(*) HOPL essay, let 
me also point you to Ingalls’ essay (which Robby pointed out to me about a year 
ago): 

 
http://web.archive.org/web/20070213165045/users.ipa.net/~dwighth/smalltalk/byte_aug81/design_principles_behind_smalltalk.html
 



(*) One of his guidelines is “abolish assignment statements”. I loved it when I 
could use this in my ECOOP keynote way back :) 




> On Jun 30, 2019, at 12:43 PM, Neil Van Dyke  wrote:
> 
> Lots of earlier HOPL papers are experience writeups relevant to the question 
> of PL design.  (For example, Alan Kay did a great history of Smalltalk, which 
> talks about more than just the language design itself, and the language 
> design was influenced by the other things.)
> 
> Separate from what's in HOPL, there are other related writeups floating 
> around.  Most recently, I saw Kent Pitman did an interesting one on Common 
> Lisp standardization (you'd also want look at whatever Guy Steele says about 
> that, John McCarthy's HOPL on Lisp in general, and various other Lisp 
> people's reports): http://www.nhplace.com/kent/Papers/cl-untold-story.html
> 
> Closer to home, there's Scheme.  I don't know all that's currently written up 
> about Scheme history (and it's ongoing, including with RnRS and various 
> implementations), but most of the players are still around, and they should 
> probably be encouraged to write if they haven't already.  Olin Shivers wrote 
> an account of T: http://www.paulgraham.com/thist.html
> 
> Then there's various papers and writeups on other Lisps (Clojure, Arc, Dylan, 
> more researchy), which might be interesting in what they chose to change (not 
> just added features), and why.
> 
> Separate from PL histories, and various models of computation, I think we 
> start to get into human issues like linguistics and aesthetics, and I don't 
> think that's well-understood in PL, nor does it seem to be the same for 
> everyone.  (For example, simply from looking at how people use Racket syntax, 
> put roughly, it looks like some people seem to use visual while others seem 
> purely verbal or mathematical; what happens when someone from one of those 
> categories tries to design an intuitive or convenient language for everyone, 
> but everyone isn't processing the language the same way?)
> 
> -- 
> 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/8cab8e8a-593e-a7d2-fa56-ef9b163503c5%40neilvandyke.org.
> 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/56ECF35E-2E87-436F-8A5C-FC099FDD71F8%40felleisen.org.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: resources on PL design

2019-06-30 Thread Matthias Felleisen

Sam’s advice is good. You might be able to find draft versions of ACM HOPL 
articles on the authors’ web sites (or likely others who taught from these 
articles, because many of these articles appeared before the web and some of 
the authors are dead). 

In general, I think we lack a design theory for PL. What we have is an analysis 
theory (which is often written down with interpreters and/or horizontal lines 
combined with Greek letters, and some Hebrew thrown in on occasion because we 
run out of the others). 

We also lack a design empirics, even though some first articles and 
dissertations in this direction are appearing. I just happen to be extremely 
skeptical of the results. I just don’t think we know how to ask the questions 
properly. See 
https://felleisen.org/matthias/Thoughts/The_Laffer_Curve_of_Types.html 
 for an 
idea of what I mean. 

— Matthias





> On Jun 30, 2019, at 12:05 PM, Stephen De Gabrielle  
> wrote:
> 
> Thanks. Added. 
> (despite horrible ACM paywall)
> 
> Kind regards 
> Stephen
> 
> On Sun, 30 Jun 2019 at 15:32, Sam Caldwell  > wrote:
> I'd add the HOPL proceedings to the mix:
> 
> https://hopl4.sigplan.org/track/hopl-4-papers#History-of-HOPL 
> 
> 
> Where the designers of languages often talk about their motivations, why they 
> made particular decisions, and what kinds of effects those decisions seemed 
> to have.
> 
> On Sun, Jun 30, 2019 at 7:24 AM Stephen De Gabrielle  > wrote:
> I've added EOPL and some others. I obviously haven't read all these, but have 
> added them because they refer to PL design or implementation in description 
> or TOC.
> Thanks to those who responded.
> 
> https://github.com/racket/racket/wiki/Creating-Languages#Books 
> 
> Books
> 
> Programming Languages: Application and Interpretation 
>  by Shriram Krishnamurthi (see 
> the PLAI Typed Language #lang plai-typed 
> )
> Essentials of Programming Languages  by Daniel P. 
> Friedman and Mitchell Wand (Publisher 
> )
> Design Concepts in Programming Languages 
>  by 
> Franklyn Turbak, David Gifford and Mark Sheldon
> Programming Language Pragmatics by Michael L. Scott
> Practical Foundations for Programming Languages by Professor Robert Harper
> Principles of Programming Languages: Design, Evaluation, and Implementation 
> by Bruce J. MacLennan
> Advanced Programming Language Design 
> 
>  by Raphael Finkel
> Lisp in Small Pieces  
> by Christian Queinnec and covers 'semantics and the implementation of the 
> whole Lisp family of languages, namely Lisp, Scheme and related dialects. It 
> describes 11 interpreters and 2 compilers'
> Structure and Interpretation of Computer Programs - teaches computer science 
> by teaching students how to implement interpreters. (see also the Racket 
> #lang sicp designed to go with the book 
> )
> 
> 
> On Fri, Jun 28, 2019 at 1:13 PM Stephen De Gabrielle  > wrote:
> Hi,
> 
> I'm looking for resources on PL *design*., i.e. deciding what to make and how 
> to assess/test those design decisions,  before moving onto how to make it. 
> 
> Any additions, opinions or advice appreciated:
> Programming Languages: Application and Interpretation by Shriram 
> Krishnamurthi  https://www.plai.org/ 
> Programming Language Pragmatics by Michael L. Scott
> 
> Practical Foundations for Programming Languages by Professor Robert Harper
> 
> Design Concepts in Programming Languages (The MIT Press) by Franklyn Turbak
> 
> Kind regards,
>  
> Stephen
>  
> * the languages are not important but FYI: Cobol, vb6, vb.net 
> , C/C++, PHP, Python, c#, Java, MUMPS & JavaScript. 
> 
> -- 
> 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/CAGHj7-KOEDGxyXfQ3m2p%3D1rAHsaqTWRBHYGfmriv_Lq%3DpXdPAA%40mail.gmail.com
>  
> .
> For more options, visit 

Re: [racket-users] images for Dr Racket 7.2 (Mac)

2019-06-30 Thread Matthias Felleisen

There is a small image collection available in 2htdp/image but the idea is that 
you do such examples with your own ideas and your own images. ~~ The next 
on-line release will suggest John's mouse-click suggestion. — Matthias




> On Jun 30, 2019, at 4:31 AM, Bryan Pierce  wrote:
> 
> Yeah, that makes sense, and that works
> I think I was expecting like a set of stock images that comes with Dr Racket
> 
> On Friday, June 28, 2019 at 7:25:21 AM UTC-7, johnbclements wrote:
> I think the idea is that you can right-click on the image in the 
> documentation using your browser and save it, then use the Insert Image menu 
> in DrRacket to open the image you just saved. Does this make sense? 
> 
> John 
> 
> > On Jun 28, 2019, at 11:26, Bryan Pierce > wrote: 
> > 
> > Hello everyone!! 
> > 
> > There is probably no reason I should let this bug me so much...in fact, I 
> > know I found the answer in the documentation somewhere, but now I can't 
> > find it 
> > 
> > I installed Dr Racket to work through the HTDP book, and am at the point 
> > where they say we can copy and paste the "rocket" image or use the Insert > 
> > Insert Image... menu 
> > 
> > But when I try to use the menu, I can't find any images in the Racket 7.2 
> > folder hierarchy 
> > 
> > QUESTIONS 
> > * Are thy not installed with the Mac version of Dr Racket? 
> > * Is there a way to download the images from the Racket 
> > website 
> > 
> > I have tried for 2 hours now to try to find the answer by searching both 
> > the internet, the group, the racket website, and the documentation 
> > 
> > Any help or any nudges in the right direction would be greatly apprciated!! 
> > 
> > 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...@googlegroups.com <>. 
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/racket-users/71a98a10-2dac-4957-976b-4ff81c2fac0a%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/846ce0d4-6a5b-401d-9bad-cfc1e6717d5a%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/B5E1AE94-E732-4CB9-BC4E-166C353A8DC5%40felleisen.org.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] new or make-object?

2019-06-29 Thread Matthias Felleisen


> On Jun 27, 2019, at 6:18 AM, Amir Teymuri  wrote:
> 
> According to the docs: 
> 
> The make-object 
> 
>  procedure creates a new object with by-position initialization arguments, 
> the new 
> 
>  form creates a new object with by-name initialization arguments
> 
> 
> Is the way of arguments specification the only difference between new and 
> make-object? 

Yes, from the functional perspective of a programmer. It it matters, you may 
wish to measure the speed of make-object over new.  

-- 
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/EA3E178D-AA39-4F06-9746-460370A6AEA2%40felleisen.org.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] leetcode

2019-06-16 Thread Matthias Felleisen


We’re way way way off topic here, so I’ll 



> On Jun 16, 2019, at 3:01 PM, Neil Van Dyke  wrote:
> 
> Just to define my terms, I distinguish Leetcode-style "coding tests" from the 
> old MS-style "puzzles" that Google later adopted for a while

I equated puzzles w/ undergraduate algorithm regurgitation knowledge. 

> I'd be pleasantly surprised if Google, for example, doesn't insist on the 
> hazing ritual battery for every single one of them, however.

Yes Google knows. I spent quite some time talking to a person who analyzed the 
problem. What Google doesn’t know is what to replace it with. 

As for our undergraduates, they may not be up there with the best 
algorithms-memorizing interviews for their co-ops, but they are told to fall 
back on the HtDP design recipe. And that impresses a certain class of 
interviewers. (As it did Google.) 

> That's an interesting way of doing it, and I'll have to ruminate on it, but 
> you're hurting my advocacy argument on HN yesterday, about when macros are 
> best used in Racket. :) https://news.ycombinator.com/item?id=20191406

As I wrote. patterns in code make me so unhappy that I abstract them, using the 
minimal tool necessary. 

But when I scanned this dumb discussion you pointed me to, I couldn’t resist 
stooping down to their level :)) 

"Does it matter that for loops don't leave a stack trace? How can poor 
programmers debug them w/o a stack trace?” 

— Matthias :) 


-- 
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/A3AFB235-0702-47C3-AE2F-94AACCE2BA9F%40felleisen.org.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] leetcode

2019-06-16 Thread Matthias Felleisen



> On Jun 16, 2019, at 3:38 AM, Neil Van Dyke  wrote:
> 
> Anyone have thoughts on whether there's anything Racket can/should do 
> involving Leetcode?
> 
> If you're not familiar, Leetcode is a site with bunch of coding interview 
> problems that huge numbers of CS students and professionals work through.  
> For doing the problems on the site, there's several popular programming 
> languages to choose from (Racket and Scheme not among them).  
> https://leetcode.com/problemset/all/
> 
> I just did three of the most popular problems tonight, in Racket/Scheme, 
> offline.  (Incidentally, in the official solutions writeups of all three, I 
> ended up finding what appears to be one outright incorrect algorithm, and had 
> nits to pick in each, over the discussion and sometimes needlessly 
> inefficient coding.  And they strangely provide little-to-no test cases in 
> the official solution writeups I've seen so far, when I'd say that figuring 
> out good test cases should be a fundamental part of every solution process.)


Undergraduates from NEU routinely report that when they follow the 
design-recipe teaching (purpose, examples, tests, templating), the interviewers 
soon move them to the next stage of the process. Or shorter, I can’t count the 
students anymore who see me and say something like “the design recipe saved my 
a.. during the interview.” (And then there are those students who know better 
:) 

Of course, good companies know by now that these “puzzle” questions are bad at 
identifying good (as in above-average) sw devs. Only the average companies 
still use this method because they are way behind. You want people who think 
systematically and leav code behind that others comprehend down the line. 

And fwiw, we have anecdotes where places such as Amazon accepted students who 
coded their solutions in BSL or ISL+. 


> One thing I found with my code[1] is that it's probably not good for 
> *selling* people on Racket. f you don't know a Lisp, and you look at this 
> Racket/Scheme code as well as the Java or C++ official solution, I suspect 
> this code looks bulkier and less familiar. 


I looked at the solutions for the first problem (’sum’). I think idiomatic 
full-fledged Racket will look fine. I use d-s-r because I hate repeated 
patterns. 

;; determine indicies i, j for Vec such that (Vec i) + (Vec j) = T 
(define (find Vec T)
  (define-syntax-rule (N) (in-range (length Vec)))
  (define-syntax-rule (in k) (in-value (list-ref Vec k)))
  (for*/first ((i (N)) (j (N)) (n (in i)) (m (in j)) #:when (= (+ n m) T)) 
(list i j)))

(equal? (find '[2 7 11 15] 9) (list 0 1))

It includes a “test”. But yes, I can see how plan R5 would look very bulky 
here, except if you can figure out ‘do’. (This has been a iong running argument 
with a local colleague here who loves R5.) 


;; - - - 

You forgot [2]. 

— Matthias




> IThough, for example, one of their solutions, if you tried to really 
> understand an optimization they were doing, their coding style actually 
> obscured that, and the Scheme code could've done that same approach in a way 
> that was easier to step through exactly what's going on.[2]
> 
> Also, I suspect that going to a lot of trouble to publish better solutions, 
> and crits of the official ones, won't impress many. Although I saw one of the 
> official solutions go into excessively detailed big-O analysis, and I suspect 
> most everyone doing Leecode has Intro Algorithms as an accomplishment they 
> can rightly be proud of, I suspect that the majority of people just want to 
> survive the all-important whiteboard hazings, and the self-image/aspiration 
> after that is more "I get it done".  I suspect that Racket will already be 
> assumed to be for academics, so academic-ing Leetcode problems harder won't 
> change that, and these contrived whiteboard problems I've seen so far don't 
> really lend themselves to Racket's relative practical strengths.
> 
> I suppose one possibility might be to get Racket or Scheme considered an 
> official language for Leetcode.  Simply having it appear on the menu on 
> leetcode.com is a boost of credibility.  I doubt many employers will want to 
> see Racket/Scheme in any case right now (and schools I've seen seem to be 
> targeting a popular language, for internships and whiteboard interviews), but 
> students and professionals will see it.  Maybe: not being on that list says 
> we're definitely not relevant; being on the list says we might be. Plus a few 
> "what's this new Racket/Scheme thing?" leads.
> 
> Other ideas for involving Racket and Leetcode?
> 
> 
> [1] Style-wise, for this exercise, I did pure-functional (which was easy and 
> efficient for all of the 3 problems thus far), and in only R5RS plus Racket 
> hashes and my unit testing library, and favoring named-`let`.  FWIW, for the 
> constant factor details, I also assumed a modestly good compiler, I 
> micro-optimized a bit more than I had to (e.g., avoiding redundant branching 
> 

Re: [racket-users] The search for routy

2019-06-14 Thread Matthias Felleisen


You may be interested in 

  https://github.com/adjkant/web-sourcery (wip) 







> On Jun 14, 2019, at 3:15 AM, Gregor Kopp  wrote:
> 
> Thank you very much!
> It's hot here...
> 
> Am Freitag, 14. Juni 2019 08:58:53 UTC+2 schrieb Tom Gillespie:
> https://github.com/Junker/routy found via `racket routy git` seems right?
> 
> On Thu, Jun 13, 2019 at 11:56 PM Gregor Kopp  wrote:
> Hi!
> I found here docs: https://docs.racket-lang.org/routy/
> I'd like to try this for fast prototyping, but can't find the package as my 
> google-fu is sloppy I guess.
> Any help please, sirs and madams?
> 
> Thank you, Gregor
> 
> 
> -- 
> 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...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/df56c1d0-7626-4284-bb77-089af462dacf%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/82c97a21-0ffd-4614-a805-96e810426a1e%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/5463F325-B52F-4C7E-B7D6-C1B64178E9B8%40felleisen.org.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: 7 GUIs

2019-06-14 Thread Matthias Felleisen



> On Jun 1, 2019, at 7:47 PM, Matthias Felleisen  wrote:
> 
> 
> Someone recently mentioned the “7 GUIs” task. I spent a couple of days to 
> write up minimal solutions: 
> 
>  https://github.com/mfelleisen/7GUI/blob/master/task-7.rkt 
> 
> In my spare time, I will develop this repo in more depth (types, units, etc) 
> because it looks like a reasonably educational task.  


I have continued my work on this repo, with two major additions: 

 — Macros/ which shows how to abstract over syntactic patterns in the GUI code 
 — Typed/ which injects types according to Typed Racket’s gradual typing 
philosophy 

Both READMEs are simple experience reports. It has been fun, and I intend to 
add MVC implementations based on Units at some point soon, and perhaps a bit 
more. 

— Matthias

-- 
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/A167D566-F645-460E-9155-CC0F33043159%40felleisen.org.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: nannou

2019-06-11 Thread Matthias Felleisen

big-bang is intended for beginners. I understand that it can be used beyond the 
intended course material but I want to say that “adult programmers” are better 
off with the underlying graphics tool box :) 



> On Jun 11, 2019, at 8:10 AM, Darren Newton  wrote:
> 
> I spent a couple of weeks working through Daniel Shiffman's The Nature of 
> Code 
> 
>  approximating Processing with Typed Racket. It was pretty fun, but I had to 
> work up a lot of basics on my own (and also moved from an OO to functional 
> design using Big Bang). It would be very cool indeed to see a more fully 
> featured creative graphics platform develop in Racket. 
> 
> On Tuesday, June 11, 2019 at 1:35:59 AM UTC-4, Neil Van Dyke wrote:
> A platform for multimedia artist programmers is using Rust.  I think 
> it'd be interesting to see how what has been and could be done in Racket 
> (including DSLs) could compare.  https://nannou.cc/  
> 
> 
> -- 
> 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/ac00bfbb-e48b-4882-93b5-b0a90de2318e%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/E5036E1B-FD14-44CC-8EF1-959FFF42EA81%40felleisen.org.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] macros and let/cc

2019-06-03 Thread Matthias Felleisen



> On Jun 3, 2019, at 12:33 PM, Kevin Forchione  wrote:
> 
> Oh! I see! That solves the expansio issue! Wonderful. You’ve opened up a 
> whole new set of possibilities for me. Thanks, Matthias.


I am glad I sent my solution a second time :) 

-- 
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/4727251D-33B3-4C88-A99E-F13F4E417AD6%40felleisen.org.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] macros and let/cc

2019-06-03 Thread Matthias Felleisen


Or, 

#lang racket

(require (for-syntax ) racket/stxparam)

(define-syntax-parameter return (syntax-rules ()))
(define-syntax-parameter false (syntax-rules ()))

(define-syntax fn
 (syntax-rules ()
   [(_ (arg ...) body ...)
(λ (arg ...)
  (let/cc fn-exit
(syntax-parameterize ([return (syntax-rules () [(_ x) (fn-exit x)])])
  (syntax-parameterize ([false (syntax-rules () [(_) (return #f)])])
body ...]))

((fn (x y) (when (< x y) (return x)) y) 2 30) ; => 2
((fn (x y) (when (< x y) (false)) y) 2 30)   ;=> #f



-- 
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/B99E2A20-68EE-46C3-B8F4-2066F3C063CD%40felleisen.org.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] macros and let/cc

2019-06-03 Thread Matthias Felleisen
#lang racket

(require (for-syntax ) racket/stxparam)

(define-syntax-parameter return (syntax-rules ()))

(define-syntax fn
  (syntax-rules ()
[(_ (arg ...) body ...)
 (λ (arg ...)
   (let/cc fn-exit
 (syntax-parameterize ([return (syntax-rules () [(_ x) (fn-exit x)])])
   body ...)))]))

(define-syntax false
  (syntax-rules ()
[(_) (return #f)]))


((fn (x y) (when (< x y) (return x)) y) 2 30) ; => 2
((fn (x y) (when (< x y) (false)) y) 2 30)   ;=> #f

-- 
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/18038548-A78C-487B-A2A8-7F1C864903BF%40felleisen.org.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] macros and let/cc

2019-06-03 Thread Matthias Felleisen


My code run your examples. Whay is missinng? 



> On Jun 3, 2019, at 11:36 AM, Kevin Forchione  wrote:
> 
> 
> 
>> On Jun 3, 2019, at 4:54 AM, Alex Knauth  wrote:
>> 
>> 
>> 
>>> On Jun 3, 2019, at 1:02 AM, Kevin Forchione  wrote:
>>>> On Jun 2, 2019, at 7:13 PM, Matthias Felleisen  
>>>> wrote:
>>>>> On Jun 2, 2019, at 9:41 PM, Kevin Forchione  wrote:
>>>>> 
>>>>> Hi guys,
>>>>> I’ve been working with macros and let/cc and have a situation where I 
>>>>> have the 2nd macro bound to the let/cc return of the first. No idea how 
>>>>> I’d do that, but here’s an example of what I’m attempting to do:
>>>>> 
>>>>> #lang racket
>>>>> 
>>>>> (require (for-syntax racket/syntax))
>>>>> 
>>>>> (define-syntax (fn stx)
>>>>>  (syntax-case stx ()
>>>>>[(_ (arg ...) body0 body ...)
>>>>> (with-syntax ([return (format-id #'body0 "~a" #'return)])
>>>>>   #'(λ (arg ...) (let/cc return body0 body ...)))]))
>>>>> 
>>>>> (define-syntax (false stx)
>>>>>  (syntax-case stx ()
>>>>>[(_) #'(return #f)]))
>>>>> 
>>>>> ((fn (x y) (when (< x y) (return x)) y) 2 30) ; => 2
>>>>> ((fn (x y) (when (< x y) (false)) y) 2 30)   ;=> #f
>>>>> 
>>>>> My thought is that the 2nd macro doesn’t know about the 1st macro except 
>>>>> perhaps through the six of compile time… so that if I had define-syntax 
>>>>> working with a lambda I’d have all the pieces available in the (fn …) but 
>>>>> not sure what tools I might use to accomplish that.
>>>>> 
>>>>> Any ideas are appreciated!
>>>> 
>>>> This situation calls for syntax-parameters in my mind: see docs, too — 
>>>> Matthias
>>> 
>>> Hmmm. A cursory glance at some of the examples suggests I’ll have to do 
>>> some exploring on this. One issue that it looks like I’ll have to work out 
>>> is that “false” in my example needs to translate to “(return #f)” and I’m 
>>> not sure at this stage where a syntax-parameterize statement would be 
>>> positioned in the fn macro
>> 
>> It should go around the same set of expressions that the `return` identifier 
>> would have been unhygienically bound in. For this example, that means around 
>> `body0 body ...`, or in context:
>> 
>> (λ (arg ...) (let/cc k (syntax-parameterize ([return ( #'k )]) body0 
>> body ...)))
>> 
>>> (or how it would know to use it unless it could interrogate the body list 
>>> looking for that value. That might be what I’d need to do here…
>> 
>> I'm not sure what you mean by interrogate the body, but if you're referring 
>> to the syntax-parameterize needing access to the continuation bound by 
>> let/cc, then your right. That's why in the example above, the 
>> syntax-parameterize needs to be inside of the let/cc where `k` is bound, and 
>> the new parameter value needs to refer to `k`. Is that what you meant?
> 
> That’s what I was thinking, but the transformation would have to be something 
> more like:
> 
> (let/cc return
> (syntax-parameterize ([false #'(return #f)]) body0 
> body ...]))
> 
> And that doesn’t work. I imagine that would expand into ((return #f)). 
> 
> Kevin

-- 
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/4F2802CF-7FF0-4C44-8843-97D6FC448239%40felleisen.org.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] macros and let/cc

2019-06-02 Thread Matthias Felleisen


> On Jun 2, 2019, at 9:41 PM, Kevin Forchione  wrote:
> 
> Hi guys,
> I’ve been working with macros and let/cc and have a situation where I have 
> the 2nd macro bound to the let/cc return of the first. No idea how I’d do 
> that, but here’s an example of what I’m attempting to do:
> 
> #lang racket
> 
> (require (for-syntax racket/syntax))
> 
> (define-syntax (fn stx)
>  (syntax-case stx ()
>[(_ (arg ...) body0 body ...)
> (with-syntax ([return (format-id #'body0 "~a" #'return)])
>   #'(λ (arg ...) (let/cc return body0 body ...)))]))
> 
> (define-syntax (false stx)
>  (syntax-case stx ()
>[(_) #'(return #f)]))
> 
> ((fn (x y) (when (< x y) (return x)) y) 2 30) ; => 2
> ((fn (x y) (when (< x y) (false)) y) 2 30)   ;=> #f
> 
> My thought is that the 2nd macro doesn’t know about the 1st macro except 
> perhaps through the six of compile time… so that if I had define-syntax 
> working with a lambda I’d have all the pieces available in the (fn …) but not 
> sure what tools I might use to accomplish that.
> 
> Any ideas are appreciated!
 

This situation calls for syntax-parameters in my mind: see docs, too — Matthias



#lang racket

(require (for-syntax ) racket/stxparam)

(define-syntax-parameter return (syntax-rules ()))

(define-syntax fn
  (syntax-rules ()
[(_ (arg ...) body ...)
 (λ (arg ...)
   (let/cc fn-exit
 (syntax-parameterize ([return (syntax-rules () [(_ x) (fn-exit x)])])
   body ...)))]))

(define-syntax false
  (syntax-rules ()
[(_) (return #f)]))


((fn (x y) (when (< x y) (return x)) y) 2 30) ; => 2
((fn (x y) (when (< x y) (false)) y) 2 30)   ;=> #f

-- 
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/7A495B17-F49A-41BE-8DED-8EC34D4FE61F%40felleisen.org.
For more options, visit https://groups.google.com/d/optout.


[racket-users] 7 GUIs

2019-06-01 Thread Matthias Felleisen

Someone recently mentioned the “7 GUIs” task. I spent a couple of days to write 
up minimal solutions: 

 https://github.com/mfelleisen/7GUI/blob/master/task-7.rkt 
 

In my spare time, I will develop this repo in more depth (types, units, etc) 
because it looks like a reasonably educational task. 


-- 
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/9A5BBCC3-C65A-4BFD-8C37-F7F35BCF39E7%40felleisen.org.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Macro help

2019-05-24 Thread Matthias Felleisen

Let me propose the use of syntax-parse as an alternative here. I think it 
clarifies the purpose of the maco. — Matthias


#lang racket

(require (for-syntax syntax/parse))

#; (aux a (b (* 2 pi)) c (d pi))
;; =>
#; (define-values (a b c d) (values #f 6.28318530717958 #f 3.141592653589793))


(begin-for-syntax
  (define-syntax-class optionally-initiliazed
(pattern (lhs:id rhs:expr))
(pattern lhs:id #:attr rhs #'#f)))

(define-syntax (aux stx)
  (syntax-parse stx
[(_ p:optionally-initiliazed ...) #'(define-values (p.lhs ...) (values 
p.rhs ...))]))

(aux a (b (* 2 pi)) c (d pi))




> On May 24, 2019, at 12:52 AM, Michael Murdock MacLeod 
>  wrote:
> 
> Does this work? It uses a helper function, `prune`, to parse the var-val 
> clauses.
> 
> #lang racket
> 
> (define-for-syntax (prune stx)
>  (syntax-case stx ()
>[()
> #'()]
>[((var val) others ...)
> (cons #'(var val)
>   (prune #'(others ...)))]
>[(var others ...)
> (cons #'(var #f)
>   (prune #'(others ...)))]))
> 
> (define-syntax (aux stx)
>  (syntax-case stx ()
>[(_ terms ...)
> (with-syntax ([((var val) ...) (prune #'(terms ...))])
>   #'(define-values (var ...) (values val ...)))]))
> 
> (aux a (b (* 2 pi)) c (d pi))
> a
> b
> c
> d
> 
> ;; output shown below
> 
> #f
> 6.283185307179586
> #f
> 3.141592653589793
> 
> On Thursday, May 23, 2019 9:41:17 PM PDT Kevin Forchione wrote:
>> Hi guys,
>> I’ve been wracking my brains all day trying to come up with a macro that
>> would convert this syntax:
>> 
>> ;; (aux a (b (* 2 pi)) c (d pi))
>> ;; => (define-values (a b c d) (values #f 6.28318530717958 #f
>> 3.141592653589793)
>> 
>> 
>> I’m missing some part of the picture. The closest I’ve come is to create a
>> list of the pairs:
>> 
>> #lang racket
>> 
>> (define-syntax (aux stx)
>>  (syntax-case stx ()
>>[(_ (var val)) #'`((var ,val))]
>>[(_ var) #''((var #f))]
>>[(_ (var0 val0) var1 ...) #'(append `((var0 ,val0)) (aux var1 ...))]
>>[(_ var0 var1 ...) #'(append '((var0 #f)) (aux var1 ...))]))
>> 
>> (aux a (b (* 2 pi)) c (d pi)) ;=> '((a #f) (b 6.283185307179586) (c #f) (d
>> 3.141592653589793))
>> 
>> 
>> Any help is greatly appreciated!
>> 
>> Kevin
> 
> 
> -- 
> 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/2893163.LJ05K77S5N%40alphtsr.
> 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/A0B65B5E-0244-4E7C-89E5-24ED2CDF69EB%40felleisen.org.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Abstract run times (HTDP)

2019-05-24 Thread Matthias Felleisen



> On May 24, 2019, at 6:27 AM, Sean Kemplay  wrote:
> 
> Hi all,
> 
> I trying to work out the ART of the sum-tree question from HTDP2e. 
> 
> I have worked through the book before however am going through it again, this 
> time am doing every exercise - this is not homework!
> 
> Here is my data defenitions, examples, a function ror summing up the contents 
> and tests -
> 
> ; A Pair is a list of two items
> 
> ; A Number-Tree is one of:
> ; Number
> ; [Pair-of Number-Tree]
> ; Examples -
> ; 0
> ; (list 0 1)
> ; (list (list 1 2) 3)
> ; (list (list 1 2) (list 3  4))
> ; (list (list (list 1 2) (list 3 4)) (list (list 5 6) (list 7 8)))
> ; (list (list (list (list (list (list (list 8 7) 6 ) 5) 4) 3) 2) 1)
> 
> ; Number-Tree -> Number
> ; Sum up all numbers in nt
> (check-expect (sum-list 0) 0)
> (check-expect (sum-list (list 1 2)) 3)
> (check-expect (sum-list (list (list 1 2) (list 3  4))) 10)
> (check-expect (sum-list(list (list (list 1 2) (list 3 4)) (list (list 5 6) 
> (list 7 8 36)
> (check-expect (sum-list (list (list (list (list (list (list (list 8 7) 6 ) 5) 
> 4) 3) 2) 1)) 36)
> (define (sum-list nt)
>   (cond [(number? nt) nt]
> [else (+ (sum-list (first nt))
>  (sum-list (second nt)))]))
> 
> 
> Using a balanced tree my analysis shows an ART of n^2 to run sum-list where n 
> is the depth of the tree
> (sum-list(list (list (list 1 2) (list 3 4)) (list (list 5 6) (list 7 8
> 
> 
> Using avery unbalanced tree with all nodesheading down to the left my 
> analysis shows an ART of 2n - or just n when the constant is removed.
> (sum-list (list (list (list (list (list (list (list 8 7) 6 ) 5) 4) 3) 2) 1))
> 
> So the unbalanced tree in this case where all nodes need to be visited would 
> be better?


Equally good. 


> A BST a search function would be better with a balanced tree but not sum-tree?

Yes. 


> Could someone possibly comment whether I am on the right track here?

Good job. 




-- 
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/6A4AA4C8-A08B-4C5F-832D-DAB6FF4E150B%40felleisen.org.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] chez-runner plugin

2019-05-22 Thread Matthias Felleisen



Off topic. ~~ It is ironic how 23 years after we started out and had an option 
for DrRacket, née DrScheme, to run its programs in Chez instead Mz .. and now 
we’re getting back to that :) 



> On May 22, 2019, at 11:10 AM, 'Paulo Matos' via Racket Users 
>  wrote:
> 
> Hi,
> 
> It seems you are referring to this DrRacket plugin:
> https://github.com/Syntacticlosure/chez-runner
> 
> Optimally Syntacticlosure should be able to help a lot more than I can
> and if what I say doesn't make sense, I suggest you open an issue with
> your question at :
> https://github.com/Syntacticlosure/chez-runner/issues
> 
> However, I quickly glanced at the code and it seems it's a plugin for
> DrRacket that simply calls `scheme --script` with what you have in the
> definitions once you click the button `Run Chez`.
> I suggest you start DrRacket, look for the button. If it's not there,
> report an issue using the link above.
> 
> Paulo
> 
> On 22/05/2019 15:34, francesco bennardo wrote:
>> Someone knows home to use the "chez-runner" plugin? I've installed it
>> but do not works.
>> 
>> -- 
>> 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/704b5a48-9e5f-4850-b92f-98dbef014472%40googlegroups.com
>> .
>> For more options, visit https://groups.google.com/d/optout.
> 
> -- 
> Paulo Matos
> 
> -- 
> 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/22979faf-7823-d97a-5a33-56d4cfb6a2df%40linki.tools.
> 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/6DC30255-B33F-4820-86B9-CA4D887CB454%40felleisen.org.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Haskell

2019-05-15 Thread Matthias Felleisen



> On May 15, 2019, at 1:26 PM, Josh Rubin  wrote:
> 
> Type inference; laziness as the default; the language forces me to think in a 
> different way than racket (or scheme) makes me think.
> 
> The examples I have seen have a breath-taking level of abstraction that 
> appeals to the mathematician in me.


That’s precisely why developers don’t really take to 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 racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/3BE177C3-A2E8-493D-94EA-BA82E66EC899%40felleisen.org.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: Keeping my mind sharp

2019-05-11 Thread Matthias Felleisen


> On May 11, 2019, at 8:41 PM, Josh Rubin  wrote:
> 
> 
> This is going to be easier than I thought. Nobody told me (mostly-equal? 
> Racket Scheme)
> 
> Racket seems to be a superset of the Scheme I know, with more restrictions on 
> mutation. I was conservative about mutations. My worst habit was using 
> "reverse!" and "append!". They are used in stereotypical ways or hidden 
> behind a layer of data abstraction, so they won't cause trouble. I need to 
> box some stuff. Many of the things I used macros for are now natively 
> supported. Old style macros are still there until I learn the shiny new 
> hygienic macros. 
> 
> I have to relearn the programming environment - editing, debugging, and 
> packaging. I want to know what is underneath the surface. As someone told me, 
> I really should learn git.


Josh, 

as the old guy on the Racket team, welcome to our world. I am so old, I was 
almost on the Texas Instrument Scheme team :) As you discovered Racket is a 
descendant of Scheme. I’d like to use the phrase it is Scheme’s heir but that 
would mean Scheme is daed, but the species of cockroach doesn't die out. 

As several people mentioned, you want to 

— port some sample programs from your 1980s TI Scheme days to Racket 
— .. other than the removal of mutable lists that will work. 

Let me recommend a second step. Find some of the modern features of Racket to 
make the code Racket-y. That’s what we call it when code uses the most basic 
Racket ideas: 

— https://docs.racket-lang.org/style/index.html?q=Style 
 
— use modules to split your code into comprehensive units, use nested 
defines, mingle them with expressions 
— if you touched CLOS, we have a class system with mixins 
— trade map for for/list and friends 
(https://docs.racket-lang.org/reference/for.html?q=for%2Flist 
); loops that don’t 
need set! 

The third step would be to design a language that makes your programs “just 
run”, because Racket’s major trick is “language-oriented programming”. 

One step on the way to #lang’s is to re-learn macros. Texas Instruments dabbled 
with Kohlbecker’s hygienic macros but don’t be confused about two different 
things that got conflated back then: 

— macros that get lexical scope right for you while you don’t have to 
think about most of the time 
— macros that use pattern-matching facilities to check basic properties 
of the surface 

Once you have basic macros down, you will climb the hill to macro design 
patterns. But I am sure we will hear from you before that, and as you can tell, 
people will help out 

— Matthias

 



-- 
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/07B9D909-51A0-4CE2-8690-C28A2D5AA0E2%40felleisen.org.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] tilda - a threading macro full of itself

2019-05-07 Thread Matthias Felleisen


> On May 7, 2019, at 1:29 PM, zeRusski  wrote:
> 
> It just names the threaded value. Did I overlook anything?
> 
> That's right, nothing fancy. Think let-binding the threaded value at that 
> point. #:with id ~ would achieve the same thing, so as it is now #:as is 
> redundant. With #:do both #:with and #:as are redundant, really.
>  
> Let me point out that if ~> specified an identifier (as suggested in my first 
> response) you could co-mingle two threaded computations, keeping separate 
> concerns that don’t matter as opposed to bundling them up in structs or lists 
> or whatever you have to do if you have only one. At first I thought #:as 
> would you let you do so, but that’s not correct.
> 
> Ok, this one I don't quite understand. My first thought went as far as to 
> weave multiple computations where each #:as would capture continuations and 
> macro would keep these "threads" separate, but now I'm thinking you mean this:
> 
> (~> 1 #:as ~a
> ;; now ~a is being threaded
> (add1 ~a)   ;=> 2
> 2 #:as ~b
> ;; now ~b is being threaded
> (add1 ~b)   ;=> 3
> ;; simply use whatever ~a was last
> (+ ~a ~b)   ;=> 5
> #:as ~a
> ;; continue to thread ~a
> (add1 ~a)   ;=> 3
> (list ~a ~b))
> ;; => (list 3 5)

Think: 

(~> (x 0)
  (add1 x) 
  (sin 
(~> (y  1)
  (sub1 y] 
  (+ x y)))
  (* pi x))

This looks equally simple and is equally easy to read. If you wish to emphasize 
the “hole variable” make sure its name has a certain shape, say ~x. 
But now the threading has precise syntactic boundaries, and the implementation 
gets away without any assignments (which I assume #:as uses). 

— Matthias

-- 
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/227C9002-72D0-45DD-939A-9D55F4833403%40felleisen.org.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] tilda - a threading macro full of itself

2019-05-07 Thread Matthias Felleisen



> On May 7, 2019, at 9:39 AM, zeRusski  wrote:
> 
> I asked in a separate thread how one debugs set of scopes in Racket macros. I 
> appreciate the question may read a bit hand-wavy and abstract, so I split out 
> the piece of code I had in mind into a separate package so that interested 
> Racketeers could have a look and their time permitting maybe even suggest 
> improvements.
> 
> Tilda is nothing but an opinionated threading macro. Even though "threading" 
> macros punctuate all of my Clojure code I've been mostly making do without 
> them in Racket. I was just being lazy tbh. I finally caved but instead of 
> using off the shelf implementation I turned this into a nice exercise in 
> macrology.
> 
> https://github.com/vkz/tilda
> 
> README shows off its capabilities with silly but hopefully sufficient 
> examples.
> 
> If you have 5-10min on your hands and would like to help me learn, I'd 
> appreciate PRs that improve or critique my code. Obviously, feel free to 
> write here, but Github may provide a nicer interface to discuss code.
> 
> Also, see if you can break it:
> - break scoping rules,
> - hit an error that doesn't point to correct location with errortrace on etc.


Let me point out that if ~> specified an identifier (as suggested in my first 
response) you could co-mingle two threaded computations, keeping separate 
concerns that don’t matter as opposed to bundling them up in structs or lists 
or whatever you have to do if you have only one. At first I thought #:as would 
you let you do so, but that’s not correct. It just names the threaded value. 
Did I overlook anything? 

— Matthias

-- 
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/9E6E2826-4DF8-419F-8321-3E4D432F3D5F%40felleisen.org.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] how do you read, manipulate, debug scope sets?

2019-05-06 Thread Matthias Felleisen



> On May 6, 2019, at 10:53 AM, zeRusski  wrote:
> 
> Suddenly I find myself playing games with hygiene and not really knowing the 
> rules.


Hygiene is a default not an absolute. The idea of hygiene is that, unless the 
macro writer goes out of his way, the expander assumes that identifiers coming 
from the macro’s input and those introduced by the macro (AND identifiers 
defined and used in the context of the macro definition vs identifiers defined 
in the macro’s use context .. which is not your current problem) are not 
related. 

If you, as a macro writer, wish to break this default assumption, you need to 
work for it. 

The macro system allows certain manipulations of scope. You have discovered 
syntax-local-introduce and its use for flipping scopes. And yes, there are more 
games you can play and you may wish to explore those but they are not for 
situations like yours. [In your specific example, I think it is often better to 
pass the identifier into the macro.] For examples, you may wish to look at 
Alexis’s Hackett implementation. Not all of what you asked for is doable, and I 
can’t even imagine you’d need all of these. 

— Matthias


-- 
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] Stack trace

2019-05-04 Thread Matthias Felleisen


> On May 3, 2019, at 4:17 AM, Mark Engelberg  wrote:
> 
> f tracing is not easily available in BSL, my ideal would be that every error 
> prints out not only the function/line where the error occurred, but also the 
> input(s) to the function which triggered the error.  (Example: a function 
> containing a cond, and every branch tests as false, so it reports an error -- 
> but it currently doesn't tell you what the input was which caused all the 
> cases to fall through).  Even without a full stacktrace, that would be 
> incredibly useful. It gives you something to reason about, something to build 
> a failing test case which you can then try to fix. Any preferences or 
> settings that can be tweaked to achieve something like this? I showed my 
> student how to build an else case with (error x) to print the value of input 
> x if all the cases fall through, but would prefer a more automatic approach.


Hi Mark, 

I think this is a good idea. and we should be able to implement this, but I am 
not sure yet that we can do it w/o abandoning PITCH (proper implementation of 
tail-calls, extra H). Perhaps function calls could store their inputs in the 
continuation marks that John’s stepper places on the stack and a re-defined 
error could retrieve them from there. 

Having these arguments, students could then formulate test cases and thus debug 
their functions. 

For now, I think adding the ‘else’ case with error is the best idea (of course, 
not doable if there’ no ‘else’). 

— Matthias

p.s. But please do teach your students the design recipe so that they have a 
test suite available no matter what. 

-- 
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: RacketCon: These 8 INSANE talks about Racket will change your life! I can't believe #7! --- (ninth RacketCon) on July 13th, 2019 --- Speakers Announced!

2019-04-29 Thread Matthias Felleisen

Yes, Jay is about to send it out to people who signed up and/or asked for 
financial help. — Matthias




> On Apr 29, 2019, at 9:30 PM, calminfe...@gmail.com wrote:
> 
> For Racket School is there any information yet about scoring a dorm room? Or 
> if preferred any conference rates at any near by hotels during Racket School 
> or Racket Con?
> 
> On Thursday, April 25, 2019 at 4:06:41 PM UTC-4, Jay McCarthy wrote:
> (ninth RacketCon) on July 13th, 2019 
> 
> Speakers Announced! 
> 
> https://con.racket-lang.org/  
> 
> Sign up for RacketCon! 
> 
> See you in Salt Lake City! 
> 
> -- 
> 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 
> .
> 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] Are syntax transformations tree automata?

2019-04-23 Thread Matthias Felleisen


The coimputational power of Racket’s syntax transformation system is equivalent 
to that of Turing machines. [[ The expressive power is a bit limited and we’re 
working on expanding it, but I don’r think you’re asking about this. ]] — 
Matthias




> On Apr 23, 2019, at 7:29 AM, Ilnar Salimzianov  wrote:
> 
> 
> Hi all!
> 
> I was glancing over these books [1] and [2] on tree automata.
> 
> I assume that Racket's macro system / syntax transformations fall under
> the category of tree transducers.
> 
> Can anybody please point me to a paper which describes its expressive
> power in formal terms, if any?
> 
> The reason I ask is that one of the google-summer-of-code projects for
> apertium.org I'm involved with is to implement a recursive transfer
> system for translating natural languages.
> 
> I'm curious how the proposed system compares to racket's of the shelf
> pattern matching's or macros' expressiveness.
> 
> Such a paper will probably be above my head at this time, but if I knew
> that both the transfer system being developed at apertium and Racket's
> pattern matcher are actually, say, something called "synchronous context
> free grammars", it would be clear that there's not much point to develop
> something exactly like that from scratch at apertium.
> 
> Best,
> 
> Ilnar
> -- 
> GPG: 0xF3ED6A19
> 
> [1] https://arxiv.org/abs/1509.06233
> [2]
> https://gforge.inria.fr/frs/?group_id=426_id=3091#tata-_2008-11-title-content
> 
> -- 
> 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] Being a good macro citizen: patterns to follow for good error reporting

2019-04-21 Thread Matthias Felleisen


> On Apr 21, 2019, at 6:48 AM, zeRusski  wrote:
> 
> I just had an epiphany, or rather a very painful revelation, that if your 
> macro does not report errors in terms of user code, say, when inputs are 
> wrong, you ought to be ostracized by the community if not banished from any 
> social interactions altogether. You don't deserve the good life. Solitary 
> confinement, damn it, until you've repented your sins, for you have sinned!


This was the problem I formulated in slightly more polite words to launch Ryan 
C’s dissertation on his dissertation research in ’03. 


> 
> Every macro has a good path - one that lets us figure what it should expand 
> into. I doubt I'm alone in merrily banging out said expansions without so 
> much as a single thought about all the bad paths the macro can take. It's 
> gotten painfully obvious lately, that if I don't take care to capture such 
> erroneous states and expansions, my macro may as well be broken, as in 
> completely wrong, even if it does the right thing for correct inputs.
> 
> Sadly, I don't think I have any systematic approach to being a good citizen 
> here, nor is my mental model for syntax objects I produce has an entry for 
> good locations and context. First, I noticed that I started to use syntax/loc 
> in place of #' everywhere I produce syntax objects. Then more pain led me to 
> discover a combination of ~describe pattern with #:context syntax-parse 
> option. And, I tell ya they are MAGICAL! Both were learnt through hardship 
> and pain, s


Yeap, this is part of the result of this research. See my second lecture from 
Racket School ’18.


BTW, for all those reading this far, we’re running another Racket School. 
Priomised I’ll lecture less and Jay will do better :) 




> o I wonder if there is a compendium of patterns that I should be cognizant of 
> to avoid at least some of that pain as I push Racket harder?
> 
> Could people maybe share relevant examples, or point out Racket machinery 
> that may not be immediately relevant but one should have at least passing 
> knowledge of to recognize when it may come in handy?
> 
> Is this too broad of a request?


No, even with syntax-parse and define-syntax-class around, we still need guides 
for people who enter Macroland so that they find their way to the good 
waterholes. Kind of like a cross between AppleMap and Yelp. 

— Matthias

-- 
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] From HtDP to Racket

2019-04-20 Thread Matthias Felleisen



> On Apr 18, 2019, at 12:08 PM, Luis Sanjuán  wrote:
> 
> The last month or so we all read some interesting posts about the convenience 
> of examples or docs to facilitate the transition from other languages to 
> Racket (from Python to Racket, from R to Racket, ...). Then I thought about 
> another non-Racket languages that no one mention, if I recall well, for which 
> such examples would be more than helpful, *SL languages ;)
> 
> Of course, The Realm is there, but more examples would be beneficial, I 
> guess. I have written something along these lines on my blog:
> 
> https://los-pajaros-de-hogano.blogspot.com/2019/04/from-htdp-to-racket-isbn-extraction-in.html
> 
> It might be full of inaccuracies or even errors. So comments, fixes, or 
> suggestions are welcomed.




Luis, this is great. Thank you for the effort. 

Here are some suggestions on how I’d re-order some of the material: 

0. Importing all of racketbase and racket/string and racket/file first is 
questionable. I would create a teachpack 

htdp2racket

that includes the functions that are needed for writing such excerpts of 
realistic programs. I’d be happy to collaborate on this and include the 
teachpack with 2htdp. 

1. I’d switch to #lang htdp/isl+ first. Your code should pose no problems for 
this #lang. (It isn’t production ready yet). 

2. Still in ISL+, I would add the 2htdp/abstraction teachpack to simplify the 
ISLcode first. I think its suport of for and match fits. 

3. A re-factoring of code must have the support of a test suite. There are 
three ways to go about this: 

(a) import rackunit into ISL+ 
(b) import racket-tests/test-engine into the racket/base program and 
run (test) at the bottom 
(c) rewrite the tests into rackunit + submdoule. 

I’d go with (b) and do an optional last step to show people how to write 
idiomatic rackunit tests. 

4. I would not use define/contract for this transition sequence. See elsewhere 
for its somewhat complex semantics when it comes to blame assignment. Instead 
when you use contracts, it might be a good time to split the module into two 
parts: 

— the main functions 
— the helpers and the large number of constant definitions plus 
contracts (yes export the contracts from here if you can keep things opaque)

You could first show how to move code into a submodule with its own 
contract-out plus a single require, then move the submodule into a file. 
(That’s how I proceed and it should be a DrRacket refactoring operation.) 


5. Years ago, I observed a PhD in our lab using point-free style in Racket. He 
came from Haskell of course. I tried it. I got close to saying negative things 
about it in the style guide. 


I am a bit disappointed that the code didn't shrink during the transformation 
but I didn’t spot immediate big gains, even with some small style guide things 
fixed. 

Again, thank you very much and please keep posting — Matthias

-- 
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] catch and bind an unbound id in a macro

2019-04-19 Thread Matthias Felleisen

Yes, I wanted to recall this trick for you and overshot :) 



> On Apr 19, 2019, at 6:04 PM, zeRusski  wrote:
> 
> Matthias, FWIW your first solution gave me a flashback from last year's 
> Summer School. I remember using this trick. Now I hope I don't forget when I 
> actually need it.
> 
> Thank you Michael and Matthias 
> 
> -- 
> 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] catch and bind an unbound id in a macro

2019-04-19 Thread Matthias Felleisen

I should have know better: 


(define-syntax (set/define stx)
  (syntax-case stx ()
[(_ id key val)
 (identifier-binding #'id)
 #`(begin
 (hash-set! h 'key val)
 h)]
[(_ id key val)
 #'(begin
 (define id (make-hash))
 (set/define id key val))]))


This isn’t exactly what you refer to with “is unbound at run-time” in other 
Lisps. 





> On Apr 19, 2019, at 5:33 PM, zeRusski  wrote:
> 
> Not quite what I had in mind. The following examples must all work without 
> errors:
> 
> #lang racket
> 
> ;; set/define defined here
> 
> (set/define h a 1)
> (set/define h a 2)
> (hash-set! h 'b 42)
> 
> (define bar (make-hash))
> (set/define bar a 1)
> 
> (define (foo)
>   (set/define local-h a 1)
>   (set/define local-h a 2)
>   (hash-set! local-h 'b 42)
>   local-h)
> 
> (foo)
> 
> Basically, if the identifier h is unbound at runtime
>   (set/define h key val)
> is the same as
>  (define h (make-hash))
>  (hash-set! h 'key val)
> 
> If h is bound
>  (hash-set! h 'key val)
> 
> -- 
> 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] catch and bind an unbound id in a macro

2019-04-19 Thread Matthias Felleisen

I had the impression that you want to create the hashtable when it’s not there 
and use it when it is: 

#lang racket

(define-syntax (set/define stx)
  (syntax-case stx ()
[(_ id key val)
 (syntax-local-value #'id (lambda () #f))
 (with-syntax ([h (car (syntax-local-value #'id (lambda () #f)))])
   #`(begin
   (hash-set! h 'key val)
   h))]
[(_ id key val)
 #'(begin
 (define-syntax id (cons #'h 0))
 (define h (make-hash))
 (set/define id key val))]))

(set/define h a 1)
(set/define h a 2)


To make sure you can see the hashtable, I also return it after every 
set/define. 



> On Apr 19, 2019, at 4:17 PM, zeRusski  wrote:
> 
> Here's what I've been trying and failing to do in Racket. The smallest 
> example I
> could think of is a macro that sets a key in a hash-table, so basically this
> transformation:
> 
>   (set/define ht 'key 42)
>   ;; =>
>   (hash-set! ht 'key 42)
> 
> 
> but if ht there is an unbound identifier it must bind it to a fresh hash 
> table. So
> basically introduce a (define ht (make-hash)) before setting the key. Assume 
> we
> run in a context where define is allowed.
> 
> Please, don't ask why I want something like this, I just do. So far tricks I 
> could
> use in other lisps failed in Racket. Here's one silly idea: catch unbound
> identifier exn. You can do it as per below or in the handler itself but it 
> doesn't
> matter cause that define is local (I think) and doesn't happen in the macro 
> use
> context.
> 
>   (require (only-in syntax/macro-testing convert-compile-time-error))
> 
>   (define (unbound-id-error? err)
> (and (exn:fail:syntax? err)
>  (regexp-match #rx"unbound identifier" (exn-message err
> 
>   (define-syntax-rule (set/define id key val)
> (unless (let/ec k
>   (with-handlers ((unbound-id-error? (λ (_) (k #f
> (convert-compile-time-error
>  (hash-set! id key val
>   (displayln "escaped")
>   (define id (make-hash))
>   (hash-set! id key val)))
> 
>   (set/define ht 'key 42)
>   ;; =>
>   ;; runs but appears that the (define ht ..) doesn't happen at top-level
> 
> This is already all sorts of ugly and it doesn't even work.
> 
> Another idea is to replace #%top for the extent of that transformer, perform
> local-expand (or some equivalent) so that #%top expansion does the job. I've 
> no
> idea how to do that, but I'm sure Racket could be persuaded. Incidentally, I'm
> curious how to create such local transformers e.g. something like 
> (let-transformer((#%top ...)) body).
> 
> Even if I knew how to do the above (local-expand #'(set/define ht 'key 42) 
> '())
> run at compile time doesn't seem to wrap unbound ht in #%top. I thought it 
> should?
> 
> So then, two questions:
> 
> 1. What's the Racket way of getting what I want?
> 
> 2. Is there a way to torture the above code into submission? Put differently 
> is
>there a way to ensure (define id (make-hash)) runs in appropriate context? 
> 
> -- 
> 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] hackernews

2019-04-16 Thread Matthias Felleisen


Can you speak in general terms at RacketCon? 



> On Apr 16, 2019, at 3:02 PM, dexterla...@gmail.com wrote:
> 
>   I use Racket daily in production at Mercury Filmworks (Disney TVA, Amazon, 
> Netflix productions among others), and I wish I could talk more about how 
> Racket helps us where it counts. If there was to be an evangelist, I'd be a 
> candidate, however 1) I don't consider myself a good Racket programmer, and 
> 2) most of what I work on can't be published. That said, I'd love to write a 
> case study on our use in production, especially Racket's role in replacing 
> Python/Bash/Csh scripts with fast, self-contained binaries. I use it for 
> everything from video formats handling (+ffmpeg) to automation to animation 
> software plugins.
> 
> Dexter
> 
> On Wednesday, December 26, 2018 at 3:51:21 PM UTC+1, Neil Van Dyke wrote:
> Stephen De Gabrielle wrote on 12/26/18 7:40 AM: 
> > How did other languages grow their audience? e.g. Ruby-on-Rails, Perl, 
> > Python, PHP, C++, Rust ? 
> 
> All of those had merits, were right place and at right time, and (except 
> Rust) really spread when there was *a lot* less noise and sheer mass of 
> stuff.  Also, some of those had very long ramps to their ultimate 
> popularity (which could give some hope to Racketeers). 
> 
> Ruby with Rails was a decent language that pushed a good model and 
> automagical conveniences for Web developer productivity, and they seemed 
> to have a good community (e.g., when I was shopping around for my new 
> research platform language, and I don't think I'd even heard of Ruby at 
> that time, one of the nice Ruby people happened to hear about my quest, 
> and emailed me, suggesting Ruby). 
> 
> We talked about Perl growth spikes here recently. 
> 
> Python started out as some guy on Usenet with a reusable extension 
> language (Tcl was another, and some RnRS implementations were another) 
> -- all 3 of them had interesting innovations and merits. (Tcl got 
> popular because of Tk GUIs, and then it has some moments in the sun for 
> earlier database-backed Web servers (as opposed to manually-edited HTML) 
> while a lot more readable than Perl, and was pushed commercially by 
> Philip Greenspun, before Sun hired Tcl creator Ousterhout, and Tcl 
> disappeared, in favor of Java and then LiveScript/JS.) 
> 
> PHP was in the early Web gold rush, when template-ish approaches were 
> attractive alternative to CGI scripts that started as Perl (or, less 
> likely, other imperative language) code that spat out HTML strings.  You 
> could also do HTML templates various other ways, including in Perl, but 
> the Web was so new, and the tools so not figured out, and everyone was 
> racing to do neat stuff (or to get VC funding, then Herman Miller office 
> furniture and launch party, and then IPO), that there was a lot of 
> random going on, and we aren't in that kind of environment anymore.  
> Well, unless you were pitching a "blockchain" startup during the BTC:USD 
> run-up a year ago -- it didn't much matter what tools you grabbed, so 
> long as you told the VCs you were doing "blockchain" (you didn't even 
> have to madlibs pitch "Our startup is like _Uber_, for _cats_!  (Can you 
> handle the sheer force of our raw innovation, unleashed!)"). 
> 
> C++ had the funding and promotional/endorsement backing of the people 
> who brought us C and Unix, and (again) there was a lot less stuff, and a 
> lot fewer programmers.  The people using C were some of the most 
> technically-skilled programmers: OS-level systems programmers (who also 
> used assembler), Unix workstation technical application/research 
> programmers, PC shrinkwrap software developers, and EEs doing software 
> bits of embedded systems.  (The corporate MIS programmers were a 
> separate group -- they mostly did database forms and reports and 
> business logic, and there seemed to be subgroups for different 
> platforms.  Much of the MIS seemed to be analogous to today's Web 
> programmers, and I'm not sure how MIS platform adoption decisions were 
> made in various kinds of organizations then.) 
> 
> Anyway, besides the Bell Labs / AT backing, I recall one thing that 
> helped push C++ was the people doing GUI and hearing about OO (with 
> references to Smalltalk), at a time when people were just reasoning 
> low-level code and ad hoc formalisms, or using pre-OO analysis and 
> design methods (structured SA and SD, ERDs, etc.), and it was really 
> easy to sell generalization/polymorphism to those people.  Plus AT was 
> saying C++ would help with mission-critical and performance-critical 
> large and complex systems, and you had workstation developers like 
> Mentor Graphics endorsing it.  Also, again, the amount of stuff and the 
> number of programmers was a lot smaller then; one anecdote: by the time 
> there was a Usenix C++ conference, it was small enough that, while 
> Stroustrup was talking during a Q in the hotel conference room (maybe 
> around the scale of 

Re: [racket-users] Is there a way to find where some feature is implemented in racket?

2019-04-16 Thread Matthias Felleisen


> On Apr 16, 2019, at 8:31 AM, zeRusski  wrote:
> 
> I suspect I'm not the first to ask, but my search-fu has failed me here. 
> Apologies if the question has already been answered on that list.
> 
> When I read Racket docs I sometimes wonder how a particular feature is 
> implemented. Looking at the source sometimes shed light or simply teaches you 
> things. However I find myself grepping Racket source and very often failing. 
> Is there a better way? Latest such encounter was s-exp meta language. I 
> assume its implemented somewhere, but grep mostly just shows scribblings or 
> its use sites. What "algo" should I employ to find relevant source of a 
> thing? Would be grand to have links from docs,  but its probably quite 
> involved.
> 


Open DrRacket. 
Use the feature in a syntactically correct way. 
Click (depending on your OS) on the identifier to open defining file. 

Like so. 

#lang racktet/base 
(provide)

Right-click on provide. 
See 

(module reqprov '#%kernel
  (#%require "define.rkt"
 (for-syntax '#%kernel
 "stx.rkt" "stxcase-scheme.rkt" "small-scheme.rkt" 
 "stxloc.rkt" "qqstx.rkt" "more-scheme.rkt"
 "member.rkt"
 "../require-transform.rkt"
 "../provide-transform.rkt"
 "struct-info.rkt"))
  
  (#%provide lib file planet submod
 for-syntax for-template for-label for-meta
 require
 only-in rename-in prefix-in except-in combine-in only-meta-in
 relative-in
 provide
 all-defined-out all-from-out
 rename-out except-out prefix-out struct-out combine-out
 protect-out
 local-require)
  .. .. ..

-- 
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] recursive function with multiple arguments

2019-04-12 Thread Matthias Felleisen

A bit of modernity yields this: 

(define (project-pop.v1 y r k thetasd t [i 1])
  (cond
[(= i t) (list y)]
[else (define theta (flvector-ref (flnormal-sample 0.0 thetasd 1) 0))
  (define y1 (* y (- r (* r (/ y k))) (exp theta)))
  (cons y (project-pop y1 r k thetasd t (+ i 1)))]))

Since this is really a fold, you could also use one of the Racket 
comprehensions to bring across the intent: 

(define (project-pop.v2 y r k thetasd t)
  (define-values (_ l)
(for/fold ((y y) (l '())) ((i (in-range 0 t 1)))
  (define theta (flvector-ref (flnormal-sample 0.0 thetasd 1) 0))
  (values (* y (- r (* r (/ y k))) (exp theta)) (cons y l
  (reverse l))

Given how short these functions are, v1 is just fine. 

Or you could stick to the original R design and write an imperative vector-fill 
function: 

(define (project-pop.v3 y0 r k thetasd t)
  (define y (make-vector t y0))
  (for ((i (in-range 1 t 1)))
(define theta (flnormal-sample 0.0 thetasd 1))
(define y@i-1 (vector-ref y (- i 1)))
(vector-set! y i (* y@i-1 (- r (* r (/ y@i-1 k))) (exp (flvector-ref theta 
0)
  y)




-- 
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] HN: "The Siren Song of Little Languages"

2019-03-26 Thread Matthias Felleisen



> On Mar 26, 2019, at 10:51 AM, 'Joel Dueck' via Racket Users 
>  wrote:
> 
> This is a blog post / discussion that seems like it could use a little 
> clarity and evangelism from the Racket world: 
> 
> https://news.ycombinator.com/item?id=19481789
> 
> I’m struggling to understand exactly what problem the blogger sees with 
> "little" languages. 


The title is a bit ambiguous, at least for people who have been around long 
enough. 

The term “Little Language” is due to Bentley and means something like a small 
programming language (usually general-purpose and equivalent to LC/TM) useful 
in a specific domain. He mentioned AWK at the time and proposed that people 
should write more of those. And people did. 

There are also small general-purpose languages as in their definitions 
(grammar, explanation of semantics, etc) are short in terms of say pages. The 
Blog post calls those Little Languages too and indeed that’s what the blog post 
is about. 

In a sense. the author of the blog post is re-arguing the case for moving from 
R5RS to R6RS. (As in making a language standard large enough so that it is 
truly useful and only serious compiler writers translate the standard into an 
implementation.) The argument produced a backlash and helped us recognize that 
Racket had moved beyond Scheme. It might be best if we don’t push too hard on 
this blog post. 

— Matthias

p.s. FWIW, there are counter-arguments to the R6RS move. Lua is a good example 
of a small gp language that is successful and is kept intentionally small so 
that each project in need of an extension language can implement it and add it. 
Somehow Roberto has managed to not make this a problem in porting code from one 
Lua to another. 


-- 
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] Error handling for the GUI

2019-03-25 Thread Matthias Felleisen



> On Mar 25, 2019, at 12:30 PM, James Platt  wrote:
> 
> 
> On Mar 25, 2019, at 12:05 PM, Matthias Felleisen wrote:
> 
>> Your exception handlers may test a contract failure to any level. You can 
>> specify this in the predicate part of with-handlers or via match on the exn 
>> within the handler function. Regexp matching works well here. 
> 
> It's obvious enough how to use regex matching for this purpose.  My concern 
> is partly that it ends up being a lot of code to write and partly that I was 
> assuming that the exact wording of error message details could change with 
> updates.  Maybe these concerns are not so bad as I anticipate.  
> 
> From The Racket Guide, I did not get the impression that you could test a 
> contract at any level.  Specifically, I don't see how you tell which 
> parameter caused the error. It could just be me not understanding something 
> that is actually obvious in the docs or maybe the docs need some work.  As 
> usual, examples would help.  I did search the web for examples of Racket code 
> including "exn:fail:contract" and found very little. 

Welcome to Racket v7.2.0.10.
> (module a racket (provide (contract-out (f (-> (-> integer? boolean? string?) 
> string? (define (f g) (g 1 "not a bool")))
> (require 'a)
> (f (lambda (x y) "hello world"))
; f: broke its own contract
;   promised: boolean?
;   produced: "not a bool"
;   in: the 2nd argument of
;   the 1st argument of
;   (-> (-> integer? boolean? string?) string?)
;   contract from: a
;   blaming: a
;(assuming the contract is correct)
;   at: stdin:2.41
; [,bt for context]

See how precise the exn message is: 2nd arg of 1st arg of f ~~ not a boolean? 

And best of all you can get at it programmatically via exn-message: 

> (with-handlers ((exn:fail:contract? exn-message)) (f (lambda (x y) "hello 
> world")))
"f: broke its own contract\n  promised: boolean?\n  produced: \"not a bool\"\n  
in: the 2nd argument of\n  the 1st argument of\n  (-> (-> integer? 
boolean? string?) string?)\n  contract from: a\n  blaming: a\n   (assuming the 
contract is correct)\n  at: stdin:2.41"

-- 
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] Error handling for the GUI

2019-03-25 Thread Matthias Felleisen



> On Mar 25, 2019, at 11:59 AM, James Platt  wrote:
> 
> 
> On Mar 23, 2019, at 5:49 PM, Greg Hendershott wrote:
> 
>> But -- contract violations aren't like that. They're about some code
>> surprising some other code. I think the only hope here is, run the
>> code enough (before the user ever does) to flush out the bad code
>> assumptions and fix them. Realistically that means having enough
>> automated tests, and running them frequently enough (like on every
>> code commit, or at least push, and you can't merge to master if tests
>> don't pass, etc.).
> 
> Yes, but contract violations are also, by definition, problems that have been 
> anticipated.  You may not know why a function is, for example, being passed a 
> specific parameter that is the wrong data type or is empty when you said it 
> should be non-empty but you do know that that is what happened.  It's enough 
> to go on for an error message.  My hope was that contracts would provide a 
> more granular set of predicates to test for each of the possible violations.  



Your exception handlers may test a contract failure to any level. You can 
specify this in the predicate part of with-handlers or via match on the exn 
within the handler function. Regexp matching works well here. 

— Mattthias

-- 
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] How to launch image display from racket REPL?

2019-03-16 Thread Matthias Felleisen

I wouldn’t have known either :)

— You are running outside of the intended context and I am sure you know that 
2htdp/image is built on top of the GUI infrastructure 
— If you look at the image teachpack, you will see section 2.2 "Image 
Interoperability” 
— there you will see that an image is “pict convertible” (satisfies the 
predicate)
— if you click thru, you are in the Pict library (specifically the predicate 
section)
— on the left, in the ToC, you will see the ‘rendering’ subsection for Picts 
— click on that one and peruse the functions supported out of there 

Would you be able to do this in 15minutes? It depends on how far you’re willing 
to click and scroll. It’s really 

 raco doc 2htdp/image 
 scroll down to section 2.2 (see ToC) 
 click on pict convertible 
 scroll up to see ToC (and notice ‘rendering’) 

Perhaps this helps someone in the future — Matthias

 



> On Mar 16, 2019, at 11:28 AM, Marc Kaufmann  wrote:
> 
> Yep, that works. 
> 
> How could I have googled this or found this solution? Or did you simply know 
> this before? I tried for 15 minutes without success, trying 'display image 
> repl' and variations on it (canvas, cli, repl).
> 
> On Saturday, March 16, 2019 at 3:59:02 PM UTC+1, Philip McGrath wrote:
> Here's one way:
> 
> Welcome to Racket v7.2.
> > (require 2htdp/image racket/gui/base (only-in pict show-pict))
> > (show-pict (empty-scene 100 100))
> 
> (The require of racket/gui/base seems to be needed for side-effect only, to 
> prevent a "racket/gui/base is not available" error. That seems like it might 
> be a bug.)
> 
> -Philip
> 
> 
> On Sat, Mar 16, 2019 at 10:48 AM Marc Kaufmann > 
> wrote:
> Hi, 
> 
> I am playing around with big-bang in 2htdp/universe and images in 
> 2htdp/image. When I launch big-bang from racket on the cli (not DrRacket), it 
> does somehow call a window and display the images with my render function. 
> However, when I want to test the render functions, I want to run them 
> separately in the cli, but can't figure out how to display images there. All 
> I get is:
> 
> > (require 2htdp/image)
> > (empty-scene 100 100)
> > (object:image% ...)
> 
> How do I open a window from the repl on which I either continuously render 
> again and again, or for each image a new such window is opened? How does 
> big-bang do it - that is maybe the way I should do it too?
> 
> Thanks,
> Marc
> 
> -- 
> 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...@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 
> .

-- 
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] Writing scribble?

2019-03-13 Thread Matthias Felleisen


esc-b, esc-f 



> On Mar 13, 2019, at 2:24 PM, Matt Jadud  wrote:
> 
> Hi all,
> 
> I assume people use DrRacket to write Scribblings.
> 
> I'll be writing text, and want to move back one word. On the Mac, most of the 
> time I can hit Option-LeftArrow, and I go back one word.
> 
> I DrRacket, this takes me back an expression, which in Scribble is a whole 
> paragraph.
> 
> Are there shortcuts for moving around Scribble documents that I don't know? 
> Do people use other tools to write Scribblings?
> 
> Cheers,
> Matt 
> 
> -- 
> 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] out of memory with streams

2019-03-12 Thread Matthias Felleisen



> On Mar 12, 2019, at 10:48 AM, bedeke  wrote:
> 
> 
> Sorry for not being clear.
> I knew that increasing the memory limit could make this run without problems 
> since the data in each cell of the stream is so small.
> I was running this example with a memory limit of 128MB.
> I made my own quick stream implementation, and this runs the above example 
> with the low memory limit without problems and without noticeable GC 
> happening. At the cost of having to reevaluate every stream from the 
> beginning.
> I was just curious if there was a stream implementation that avoids 
> memoization.


The very notion of ‘stream’ implies memoization. What I am surprised about is 
that racket/stream (unlike #lang lazy) does not memoize exceptions, which is 
even more expensive — Matthias

-- 
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] out of memory with streams

2019-03-12 Thread Matthias Felleisen


> On Mar 12, 2019, at 3:10 AM, bedeke  wrote:
> 
> Hello,
> 
> when running any of the following the program runs out of memory:
> 
> #lang racket/base
> (require racket/stream)
> 
> (stream-ref (let ([i 0])(stream-cons i (let loop ()(set! i (+ i 
> 1))(stream-cons i (loop)
> 2000)
> (stream-ref (for/stream ([i (in-naturals)]) i)
>   2000)
> 
> I guess this is because of memoization, but I was hoping that since I don't 
> keep a reference to the first element of the stream, it would be discarded. 
> This doesn't seem to be happening.
> Is there a way to disable memoization for streams? Or is there an other issue?
> 
> (the actual stream I want to build/traverse without keeping it in memory is 
> at http://pasterack.org/pastes/63574)
 

I ran this program: 

#lang racket/base

(require racket/stream)
(stream-ref (let ([i 0]) (stream-cons i (let loop () (set! i (+ i 1)) 
(stream-cons i (loop) 2000)

;; please write this: the above is Fortran in Racket 
(stream-ref (let loop ([i 0]) (stream-cons i (loop (+ i 1 2000)


I got (with serious GC happening between the two results): 

Welcome to DrRacket, version 7.2.0.6--2018-05-23(-/f) [3m].
Language: racket/base, with debugging; memory limit: 2048 MB.
2000
2000


-- 
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] define fails at runtime, where let fails at compile time

2019-03-11 Thread Matthias Felleisen



> On Mar 11, 2019, at 1:18 PM, Brian Adkins  wrote:
> 
> I want let semantics, but I've been using define more because it's preferred 
> in the Racket style guide. I don't want the behavior of define above, so 
> using letrec to get a runtime error instead of compile time error doesn't 
> make sense.
> 
> Oops - I should've used let* in my example. 


That wouldn’t change a thing in your example. 

If you meant you want a let* semantics for sequences of define, I think that’s 
a good idea. And as the author of the Style Guide, I wholeheartedly agree with 
this desire. When I replace let-s with define-s, I have gotten used to checking 
for identifier sequencing and such. But perhaps a newbie shouldn’t have to 
think that way. 

— Matthias




-- 
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] define fails at runtime, where let fails at compile time

2019-03-11 Thread Matthias Felleisen



> On Mar 11, 2019, at 11:21 AM, Brian Adkins  wrote:
> 
> I just discovered that define will fail at runtime, where let would fail at 
> compile time. Besides helping to keep the indentation level from marching to 
> the right "too much", what are the benefits of define over let?
> 
> --- snip ---
> #lang racket
> 
> (define (f n) (+ n 1))
> 
> (define (foo)
>   (define b (f a))
>   (define a 7)
>   
>   b)
> 
> (define (bar)
>   (let ([b (f a)]
> [a 7])
> 
> b))
> --- snip ---



I think your characterization is a bit misleading here. 

In ‘bar’ ‘a’ is not bound, something that Racket (and DrRacket) properly signal 
at compile time. 

In ‘foo’ ‘a’ *is* bound, because you’ve set up a mutually recursive scope. But, 
when Racket evaluates (foo) it notices that ‘a’ is bound but uninitialized, 
which is two different things. 

If you want to compare apples to apples, use a ‘letrec' instead of a ‘let' in 
‘bar'. Then you have (1) the same semantics and (2) the same error. 

— Matthias

-- 
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] lexer-parser approach in Racket [was the list of languages made with racket [Hacker News]]

2019-03-01 Thread Matthias Felleisen



> On Mar 1, 2019, at 2:29 PM, Aidan Gauland  wrote:
> 
> On 2/03/19 3:27 AM, Matthias Felleisen wrote:
>>> On Mar 1, 2019, at 2:15 AM, Aidan Gauland 
>>>  wrote:
>>> 
>>> On 24/02/19 12:08 PM, Matthias Felleisen wrote:
>>> 
>>>> 2. The means of implementation in Racket are radically different from a 
>>>> lexer-parser approach.
>>>> 
>>> Wait, does this mean that the Beautiful Racket book is leading me down the 
>>> wrong path?  I'm in the middle of the bf chapter 
>>> <https://beautifulracket.com/bf/>
>>> , which (if I am understanding it correctly, is using a lexer and a parser.
>>> 
>> Please read this comment in context. This line is a response to a particular 
>> point raised in the Reddit link of the original post. On this Reddit thread, 
>> someone seems to confuse creating DSLs with writing new syntax for 
>> more-or-less standard semantic concepts. For such people, it matters to find 
>> a conventional Lex-Yacc (replace with modern words) tool chain plus perhaps 
>> some support for backend creation.
>> 
>> [snip]
>> 
> I apologise for missing the context; I did take a look at the thread, but I 
> still misunderstood your remark initially.  Thanks for the clarification.


My response wasn’t meant as a rebuke. I really just wanted to say “the one-line 
statement is oversimplifying and you really need to look at the Reddit thread 
to understand its implications.” — Matthias

-- 
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: Types of languages Re: [racket-users] the list of languages made with racket [Hacker News]

2019-03-01 Thread Matthias Felleisen



> On Mar 1, 2019, at 12:05 PM, Stephen De Gabrielle  
> wrote:
> 
> Hi Matthias,
> (or anyone else who is available to answer :))
> 
> I'm trying to get my head around the range of possible languages in Racket.
> 
> You got me thinking how many languages seem to have embedded little 
> languages. 
> I was wondering how they fit into your categories of languages?
> 
> 3. The nature of languages ranges from 
> — stand-alone languages with ugly syntax (example: datalog)
> — #lang stand-alone DSLs (config, scribble)
> 
> Does '#lang video' fit in this group?

Yes. 


> 
> — #lang language mixins (s-expr, 2d)
> 
> Do regular #px""/#rx expressions fit in this category?

I don’t understand how #px is similar to the s-expr or at-expr or 2d #lang 
mixins. I am referring to lines such as #lang at-exp scribble. 


> 
> — embedded DSLs with mostly coarse-grained interactions with Racket 
> (redex)
> 
> would racket/class fit in this group?

I classified it with the next bullet. 

> would (require sql) fit in this group?

I think so. I haven’t used it. 


> — embedded DSLs with fine-grained interaction with Racket (the 
> language of class syntax; syntax-parse: the pattern and templated languages, 
> which interact via syn-pattern vars)
> 
> Do regular #px""/#rx expressions fit in this category?

I still don’t understand what you mean here. 

— Matthias


p.s. In my mind, format and regexp-match (and similar functions) are 
interpreters for programs in DSLs that are written down as strings. That’s my 
opening slides for HtDL (from last year). 

-- 
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] how to use union types

2019-03-01 Thread Matthias Felleisen


. . . all of which suggests that perhaps we should support blazingly fast list 
chaperones eventually :) 

-- 
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] R6RS history

2019-02-28 Thread Matthias Felleisen



> On Feb 27, 2019, at 1:42 PM, Arthur Nunes-Harwitt  wrote:
> 
> Dear Matthias,
> 
>  Would you be willing to share your thoughts about the history of 
> denotational versus operational semantics in the report?


[[ This is probably totally off topic for the list. ]]

Denotational semantics emerged as the dominant form in the 70s and 80s, 
especially in the functional/Lisp-y community, because it could express 
everything and the function from Syntax to Meaning (Scott domains) looked like 
an interpreter, which everybody (“”) knows how to read and possibly write. 

BUT, 

1. you typically want to use your semantics for something (e.g. a proof that 
what you wrote down has certain properties) 
2. you want your semantics to have some resemblance to the design principles 
(here, “Scheme as a lambda calculus …”) 

The 1980s showed that using den. sem. for many common goals was hard (e.g. type 
soundness proofs of ML; see Dams and Tofte’s work). In 1991, I worked with a 
student (Andrew Wright) to explain how these proofs could be done more easily 
with a form of operational semantics (an actual lambda calculus element) that I 
developed for my dissertation. 

The cool thing was that this new form of semantics looked as simple as the 
original lambda calculus, handled assignments and continuations just fine, and 
possessed the same mathematical properties as the original lambda calculus 
(Church-Rosser, Curry-Feys). 

By the time R6RS rolled around, Robby and his students had developed the Redex 
language far enough that we could use it to model all of Scheme, first R5RS and 
then R6RS (minus macros). By supplying an executable operational model, we 
hoped implementors could use it as an independent source of truth for their own 
work. We definitely have for many special corners of Racket and time and again 
Matthew finds a discrepancy between our models and the implementation. 
Sometimes we don’t trust the implementation and extend the model to cover this 
corner just to see whether two rather different ways of looking at things help 
us find the right way of doing things. 

If you’re curious, see https://www2.ccs.neu.edu/racket/pubs/#popl12-kfff for 
other examples. 


-- 
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] R6RS history

2019-02-26 Thread Matthias Felleisen



Let me inject some comments that make it a bit more obvious what’s happening 
here: 


> On Feb 26, 2019, at 3:33 PM, Sam Tobin-Hochstadt  wrote:
> 

RnRS meetings from 1984 thru 2003 adhere to the “unanimity rule” originating 
from the MIT group. 

In 2001, I created and ran “Scheme and Functional Programming” (SFP), a first 
annual Scheme workshop that also subsumed “Scheme Report” meetings. 


> 2003: New Scheme Standard proposed at the Scheme Workshop

At the 2003 Boston SFP, I proposed going to a majority rule so that the Scheme 
standard could grow into a useful language after a long long day, with many 
people gone. The motion passed. 

> 2006: First draft of R6RS released
> 2007: R6RS Ratified by community vote after extensive discussion and revision

I wrote an essay entitled “The R6RS is Perfect”. The certification vote 
succeeded with just a few votes more than needed (60% or 66% or something like 
that). 


> 2009: A new Scheme Standard steering committee elected by a community
> vote. The new committee reflected opposition to the R6RS.

(as in “community vote” by another Scheme workshop) 


We, the Racketeers, didn’t want to be in their way so we wrote this: 

 https://racket-lang.org/new-name.html

History is history. The future you can change, unless Gödel is right about 
Einstein’s equations and it’s practical. 

— Matthias




-- 
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: Help with generators from python land!

2019-02-23 Thread Matthias Felleisen


> I imagine some input, that is too big and should be handled one element
> at a time instead. How would one do that in Racket, when not using
> something comparable to a Python generator?


It depends on the situation specifically the interface that’s force on your
components (if any) and how you use this large piece of data. 

The simplest and cleanest solution is laziness. Here is a standard example 
from my teaching. Say your program demands a large decision tree (imagine
a strategy-based game tree). A ‘planner’ tends to visit select portions of such
a tree up to a certain depth. You can use 

 — standard lambda encodings of lazy branches 
use this if you never need to recompute values 

 — import the lazy constructs from #lang Lazy 
these cache the results of computations making it somewhat cheaper to 
recompute 

This solution is simple and elegant because the overall program remains a 
functional 
program and the simple algebraic laws of reasoning apply if you need to work 
something
out in your head. 

Stephen Chang’s dissertation shows how to discover where to insert lazy 
constructors
and strict accessors for lazy data constructions to speed up programs. It’s a 
prototype 
and someone should turn it into a full-fledge tool. 

Above and beyond this simple solution, you may wish to use 

  — generators (replaces laziness with almost the same simplicity, but they do 
use imperative control) 
  — coroutines (explicit hand-over of control, co-operative threads) 
  — threads (as in time-preempted) 
  — places (OS level parallelism) with channels of communication 
  — distributed places (like places, across different cpus possibly on 
networks) 

It’s too much detail to spell out here when/why each situation calls for what. 
But it pays 
off to implement the same problem and variants of the same problem with various 
linguistic 
means and to think about the consequences. (This is how HtDP came about.) 

— Matthias

-- 
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] Strip the lexical context from an identifier

2019-02-22 Thread Matthias Felleisen


And that’s better of course because you pick up the lexical scope, which 

  (let ([x 4]) [(my-macro x) 1 2])

shows. 



> On Feb 22, 2019, at 1:26 PM, Sam Caldwell  wrote:
> 
> You can also do this with syntax-local-introduce to remove x's use-site 
> scope*:
> 
> #lang racket
> 
> (require (for-syntax syntax/parse))
> 
> (define-syntax (my-macro stx)
>(syntax-parse stx
>  [(_ x:id)
>   #:with x- (syntax-local-introduce #'x)
>   #'(lambda (a b) x-)]))
> 
> ((my-macro a) 1 2)
> ;; 1
> 
> ((my-macro b) 1 2)
> ;; 2
> 
> (define x 3)
> ((my-macro x) 1 2)
> ;; 3
> 
> 
> 
> -Sam
> 
> * well, I think that's what's going on.
> 
> On Fri, Feb 22, 2019 at 1:21 PM Matthias Felleisen  
> wrote:
> 
> 
> > On Feb 22, 2019, at 1:08 PM, Stefano Lande  wrote:
> > 
> > Dear all,
> > 
> > first of all, I might being misusing the terminology. Sorry about it.
> > 
> > I would like to write a macro that gets an identifier and return its value 
> > in the new lexical scope created by the macro.
> > For example:
> > 
> > > (define-syntax (my-macro stx)
> >(syntax-parse stx
> >  [(_ x:id)  #'(lambda (a b) x) ]))
> > 
> > 
> > > ((my-macro a) 1 2) 
> > 1
> > 
> > >((my-macro b) 1 2) 
> > 2
> > 
> > 
> > 
> > my-macro as above of course would not work. Is possible to receive an 
> > identifier, strip the lexical context, and evaluate it in the context of 
> > (lambda (a b) body) ?
> 
> 
> Here is one way to get your macro: 
> 
> #lang racket
> 
> (require (for-syntax syntax/parse))
> (require (for-syntax racket/syntax))
> 
> (define-syntax (my-macro stx)
>   (syntax-parse stx
> [(_ x:id)
>  #:with a #'a
>  #:with y (datum->syntax #'a (syntax-e #'x))
>  #`(lambda (a b) y)]))
> 
> [(my-macro a) 1 2]
> [(my-macro b) 1 2]
> (define x 3)
> [(my-macro x) 1 2]
> 
> -- 
> 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] Strip the lexical context from an identifier

2019-02-22 Thread Matthias Felleisen



> On Feb 22, 2019, at 1:08 PM, Stefano Lande  wrote:
> 
> Dear all,
> 
> first of all, I might being misusing the terminology. Sorry about it.
> 
> I would like to write a macro that gets an identifier and return its value in 
> the new lexical scope created by the macro.
> For example:
> 
> > (define-syntax (my-macro stx)
>(syntax-parse stx
>  [(_ x:id)  #'(lambda (a b) x) ]))
> 
> 
> > ((my-macro a) 1 2) 
> 1
> 
> >((my-macro b) 1 2) 
> 2
> 
> 
> 
> my-macro as above of course would not work. Is possible to receive an 
> identifier, strip the lexical context, and evaluate it in the context of 
> (lambda (a b) body) ?
 

Here is one way to get your macro: 

#lang racket

(require (for-syntax syntax/parse))
(require (for-syntax racket/syntax))

(define-syntax (my-macro stx)
  (syntax-parse stx
[(_ x:id)
 #:with a #'a
 #:with y (datum->syntax #'a (syntax-e #'x))
 #`(lambda (a b) y)]))

[(my-macro a) 1 2]
[(my-macro b) 1 2]
(define x 3)
[(my-macro x) 1 2]

-- 
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] Help with generators from python land!

2019-02-22 Thread Matthias Felleisen



> On Feb 21, 2019, at 10:32 PM, Konrad Hinsen  
> wrote:
> 
>  The main difference, as has been pointed out before, is that Python 
> generators are more common as an idiom for solving problems that in Racket 
> would typically be approached differently.



[[ This is of course ironic in a way, given how much research the Scheme/PLT 
Scheme/Racket community did on continuations and friends and how many times 
this was motivated in the introductions to papers with “generators” 
“coroutines” “threads” and similar, now-modern ideas of control. But it’s 
better to learn and to improve than to stick with old ideas just for the heck 
of sticking with them. Use control when appropriate. ]] 

-- 
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] Transfer code from "intermediate student with lamnda" to "Pretty big"

2019-02-20 Thread Matthias Felleisen


See previous email exchanges and the require necessary to import the tests 
(test-engine/racket-tests) plus the call to the test function. 



> On Feb 19, 2019, at 2:26 PM, orenpa11  wrote:
> 
> Hi
> Is it possible to transfer code from "intermediate student with lamnda" to 
> "Pretty big"
> for exmple :
> 
> (require 2htdp/image)
> (require 2htdp/universe)
> 
> 
> (define (join-together ls1 ls2)
>   (local 
> [; help : [ListOf X] -> [ListOf X]
>  ; (help ls1) drops the invariant argument ls2
>  (define (help ls1)
>(cond
>  [(empty? ls1) ls2]
>  [else (cons (first ls1) 
>  (help (rest ls1)))]))]
> (help ls1)))
> 
> (check-expect (join-together '() '(a b c d e f)) '(a b c d e f))
> (check-expect (join-together '(a)  '(b c d e f)) '(a b c d e f))
> (check-expect (join-together '(a b)  '(c d e f)) '(a b c d e f))
> (check-expect (join-together '(a b c ) '(d e f)) '(a b c d e f))
> (check-expect (join-together '(a b c d)  '(e f)) '(a b c d e f))
> (check-expect (join-together '(a b c d e)  '(f)) '(a b c d e f))
> (check-expect (join-together '(a b c d e f) '()) '(a b c d e f))
> 
> 
> 
> Thanks,
> Or
> 
> p.s. I get the error
> 
> check-expect: undefined;
>  cannot reference an identifier before its definition
> 
> -- 
> 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] test user-interact function dont work

2019-02-17 Thread Matthias Felleisen


> On Feb 17, 2019, at 6:44 PM, Joao Pedro Abreu De Souza  
> wrote:
> 
> (check-equal?
>  (with-output-to-string
>(lambda ()
>  (with-input-from-string "input"
>(lambda ()
>  (refine-main)



Your mistake is in the above line. You want to write refine-main not 
(refine-main). 


>  "input")

-- 
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] Running raco setup from within DrRacket?

2019-02-15 Thread Matthias Felleisen



> On Feb 15, 2019, at 11:05 PM, jackhfi...@gmail.com wrote:
> 
> Whenever I change code in my package I switch over to the terminal and 
> recompile it with `raco setup`. This is slightly tedious and I’d like to be 
> able to do this from within DrRacket. But I’m not sure how to translate the 
> command `raco setup --doc-index --check-pkg-deps --tidy --unused-pkg-deps 
> --pkgs ` into a runnable racket module. I tried the following:
>   • Using `system*` didn’t work because it doesn’t search `$PATH` and so 
> it can’t find `raco`.
>   • Using `(find-executable-path "raco")` didn’t work either, it just 
> returned false.
>   • Trying to invoke the setup command using `dynamic-require` and 
> `raco/all-tools` started `raco setup` successfully, but then failed because 
> for some reason the setup command was trying to read and tidy up stale 
> DrRacket-specific zos (the stuff in `compiled/drracket` subdirectories).
> What should I do here? 


See 
https://docs.racket-lang.org/raco/setup-plt-plt.html?q=setup#%28def._%28%28lib._setup%2Fsetup..rkt%29._setup%29%29

(require setup/setup)

I think that’s what you want — Matthias



-- 
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: Little language design/implementation guidance

2019-02-13 Thread Matthias Felleisen



> On Feb 13, 2019, at 10:24 AM, Stephen De Gabrielle  
> wrote:
> 
>   • programmer (without compilers course)
>   • did compilers at degree level (can still remember it and it covered 
> design decisions, as opposed to algorithms and data structures)
>   • Beautiful Racket and/or/ https://school.racket-lang.org/#brw
>   • Racket School 'How to design Languages' 
> https://school.racket-lang.org/#htdl 
>   • http://cs.brown.edu/courses/cs173/ , PLAI, PAPL or a postgraduate 
> level (masters?)
>   • PhD and beyond
> ( I have no idea if the order I made up is right - and I don't remember the 
> dragon book covering the HCI aspects of language design) 
> 
> I suppose if you are If you are at (1) and you need help you ask someone at 
> (2) or above.


I don’t think this is a linear order. It’s more like a landscape with dots and 
connections and hyper-edges and such. In particular, 

— the PLAI course at Brown belongs into the “compiler” equivalence class, 
— a PhD does not a good DSL designer or expert consultant (on this topic) make, 
and
— the first bucket is way too coarse (some programmers have good “native” taste 
for DSLs, others should never ever program). 

And I understood that you were asking about experts who can do DSL x Domain 
stuff. But NVD’s remark and my long-time observation of where PL research is 
going triggered my rant. Sorry 

— Matthias


-- 
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] struct-info

2019-02-12 Thread Matthias Felleisen



> On Feb 12, 2019, at 5:28 PM, David Storrs  wrote:
> 
> On Tue, Feb 12, 2019 at 5:03 PM  wrote:
 
 This is nice for defining abstract types, but it can be pretty 
 inconvenient for defining plain old aggregated data types that just have a 
 bundle of fields. When defining those types as structs, consider using the 
 #:transparent option. This means "use no inspector at all" (roughly) and 
 lets `struct-info` Just Work (TM) without any inspector wrangling. The 
 downside is that other modules may be able to break your type's invariants 
 and possibly circumvent your contracts.
>>> 
>>> 
>>> That's what I expected, but it doesn't seem to work:
>>> 
 (struct person (name age) #:transparent)
 (struct-info person)
>>> #f
>>> #t
>>> 
>>> What am I missing?
>> 
>> 
>> I was stumped on this for a while, but then realized the problem:
>> 
>>> (struct-info person)
>> #f
>> #t
>>> (struct-info (person "Alyssa P. Hacker" 42))
>> #
>> #f
> 
> Ah, I see.  Thanks, I wouldn't have guessed that an instance of a
> struct satisfied `struct-type?`
> 
> On the other hand, it seems relatively easy to break these
> protections.  Is there a way to prevent that?
> 
> ; file test1.rkt
> #lang racket
> (struct person (name age))
> (provide person)



The line above exports two pieces: the constructor and compile-time information 
about the structure, including the functions as you saw. If you want to protect 
your invariants, you replace this provide with something like 

   (provide (contract-out (person (-> string natural-number/c person?

See end for a simpler way to test such things. 



> ;; end of test1.rkt
> 
> 
> ; file test2.rkt
> #lang racket
> 
> (require "test1.rkt"
> (for-syntax racket
> syntax/parse
> syntax/parse/experimental/template
> syntax/parse/class/struct-id))
> 
> (define p (person 'bob 19))
> (displayln "required ctor only of a struct defined in another file.
> Can create, is opaque:")
> p
> (displayln "struct-info returns (values #f #t) since the struct isn't
> inspectable here:")
> (struct-info p)
> (define-syntax struct-funcs (syntax-parser [(_ s:struct-id) (template
> (list s.constructor-id s.accessor-id ...))]))
> (define lst (struct-funcs person))
> (displayln "show list of constructor and accessors that we retrieved
> via macro:")
> lst
> (displayln "Fetch name ('bob) by way of accessor returned through macro:")
> ((second lst) p)
> ; Uncommenting the following will cause compilation to fail, since
> person-name was not exported
> ;(person-name p)
> ;;  end of test2.rkt
> 
> 
> ;; command line:
> $ racket test2.rkt
> required ctor only of a struct defined in another file. Can create, is opaque:
> #
> struct-info returns (values #f #t) since the struct isn't inspectable here:
> #f
> #t
> show list of constructor and accessors that we retrieved via macro:
> '(# # #)
> Fetch name ('bob) by way of accessor returned through macro:
> 'bob
> 
> -




#lang racket

(module test1 racket
  (provide (contract-out (person (-> string natural-number/c person?
  (struct person (name age)))

(module test2 racket 
  (require (submod ".." test1)
   (for-syntax racket
   syntax/parse
   syntax/parse/experimental/template
   syntax/parse/class/struct-id))

  (define p (person 'bob 19))
  (displayln "required ctor only of a struct defined in another file. Can 
create, is opaque:")
  p
  
  (displayln "struct-info returns (values #f #t) since the struct isn't 
inspectable here:")
  (struct-info p)

  (define-syntax struct-funcs (syntax-parser [(_ s:struct-id) (template (list 
s.constructor-id s.accessor-id ...))]))
  (define lst (struct-funcs person))
  (displayln "show list of constructor and accessors that we retrieved via 
macro:")
  lst
  
  (displayln "Fetch name ('bob) by way of accessor returned through macro:")
  ((second lst) p)

  ; Uncommenting the following will cause compilation to fail, since
  ; person-name
  )

-- 
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-10 Thread Matthias Felleisen


> On Feb 10, 2019, at 7:26 PM, Alex Harsanyi  wrote:
> 
> One way to do this is for `pop-abundances` to have an extra parameter, the 
> list of previous abundances, and whenever the function is called recursively, 
> it adds the current abundance to this list and passes it on to the next call. 
>  The final call will than return this result instead of the last abundance.  
> In the example below, "cons" adds to the front of the list, so "result" 
> contains the most recent values first and  this list is reversed before being 
> returned to the user.  Also, when `pop-abundances` is invoked by the user, 
> there are no "previous abundances" , so it needs to be invoked with an empty 
> list -- this is handled by a default parameter for 'result':
> 
> #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 (pop-projection A n iter [result '()])
>   (if (zero? iter)
>   (reverse (cons n result))
>   (pop-projection A (matrix* A n) (- iter 1) (cons n result
> 
> (pop-projection A n 25)
> 



Don’t use accumulators if the function has all the information: 

#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 (pop-projection A n iter [result '()])
  (if (zero? iter)
  (reverse (cons n result))
  (pop-projection A (matrix* A n) (- iter 1) (cons n result

(define (pop-projection.v1 A n iter)
  (if (zero? iter)
  (list n)
  (cons n (pop-projection A (matrix* A n) (- iter 1)

(equal? (pop-projection A n 25) (pop-projection.v1 A n 25))

-- 
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: Some concern about ChezScheme...

2019-02-09 Thread Matthias Felleisen


> On Feb 9, 2019, at 5:35 PM, ra...@airmail.cc wrote:
> 
> Could nanopass, at least in theory, fuse multiple (or even all) passes into 
> one at compile time.  To create a very efficient compiler which is also 
> logically broken down and readable in the source code?


Yes, precisely because the languages ought to be purely declarative and, 
especially in a Racket setting, could be isolated from the imperative parts of 
the language. 

No, as they currently are used in Chez because they use side-effects on 
occasion to communicate between passes. See Experience report and up-stream URL 
to Chez module. 

Great research topic, and yes, we looked into it but moved on — Matthias


-- 
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: Little language design/implementation guidance

2019-02-08 Thread Matthias Felleisen



> On Feb 7, 2019, at 7:32 PM, Neil Van Dyke  wrote:
> 
> but it might just be easier to just get a professorship instead (also 
> nontrivial). :)


Absolutely. 

* How many academic PL experts do you know that design languages? 
* How many of their languages reach an audience of more than 7? 
* How often do they repeat this? 

While there’re clearly some academic PL researchers who do all of this, the de 
facto careerization of the research job has pushed people to where the glory 
is: 

- papers 
- more papers 
- yet more papers 
— and as many citations as possible. 

So to become a professor with a high citation count, you must follow the herd 
and toe the consensus line. And what is the consensus line at the moment: 

- verification via proof assistants 
— verification via model checking 
— verification of static properties 
— synthesis, and
— the desperate need to apply ML-AI to PL (and I don’t mean OCAML here) 

In short, there really aren’t many experts. Most of these experts probably 
focus on general-purpose language design not DSL design. 

And all of this despite the fact you can easily identify 2,500 publications on 
DSLs [see the annotated bibliography of va Deursen et al. from 2000 and the 
survey of Mernik et al. from 2005]. 

;; - - - 

Now having said that, I would also provide some food for thought since y’all 
live in the Racket universe: 

— match is a DSL, most of its patterns aren’t meaningful outside of match 
— syntax pattern variables is a DSL, an extremely small one 
— syntax-case patterns is a DSL that interacts with the DSL on syntax pattern 
variables 
— syntax-case templates is a DSL different from the patterns that interacts 
with the DSL of syntax pattern variables 
— syntax-parse is a different DSL 
— . . . and up the scale 
— #lang info is a DSL 
— #lang datalog is yet a different kind of DSL 

While a course on compilers may help — parsing, static checking, code 
generation, and optimization are useful ideas — how well do they apply above. 

OK. Back to work — Matthias

-- 
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] Some concern about ChezScheme...

2019-02-08 Thread Matthias Felleisen


> On Feb 6, 2019, at 3:19 PM, George Neuner  wrote:
> 
> On Wed, 6 Feb 2019 12:50:21 -0500, Matthias Felleisen
> mailto:matth...@felleisen.org>> wrote:
> 
>>> On Feb 6, 2019, at 12:30 PM, 'Paulo Matos' via Racket Users 
>>>  wrote:
>>> 
>>> I was quite surprised to read these nanopass ideas have been around for
>>> so long.
>> 
>> 
>> 1. The educational idea came first: 
>> 
>> A Nanopass framework for compiler education. • Volume 15, Issue 5 • 
>> September 2005 , pp. 653-667
>> 
>> https://www.cambridge.org/core/journals/journal-of-functional-programming/article/educational-pearl-a-nanopass-framework-for-compiler-education/1E378B9B451270AF6A155FA0C21C04A3
>> 
>> 2. The experience report of applying the idea to a commercial compiler came 
>> about 10 years later: 
>> 
>> A Nanopass framework for commercial compiler development. ICFP ’13 , pp 
>> 343-350
>> 
>> https://dl.acm.org/citation.cfm?id=2500618 
>> <https://dl.acm.org/citation.cfm?id=2500618> 
>> <https://dl.acm.org/citation.cfm?id=2500618 
>> <https://dl.acm.org/citation.cfm?id=2500618>>
>> 
>> — Matthias
> 
> 
> The idea that a compiler should be structured as multiple passes each
> doing just one clearly defined thing is quite old.  I don't have
> references, but I recall some of these ideas being floated in the late
> 80's, early 90's [when I was in school].
> 
> Interestingly, LLVM began (circa ~2000) with similar notions that the
> compiler should be highly modular and composed of many (relatively
> simple) passes.  Unfortunately, they quickly discovered that, for a C
> compiler at least, having too many passes makes the compiler very slow
> - even on fast machines.  Relatively quickly they started combining
> the simple passes to reduce the running time.
> 


I strongly recommend that you read the article(s) to find out how different 
nanopasses are from the multiple-pass compilers, which probably date back to 
the late 60s at least. — Matthias

-- 
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] How to start a program in pretty big

2019-02-07 Thread Matthias Felleisen


As several people have mentioned in the past, you go into DrRacket and use the 
Language menu to choose Pretty Big. 



> On Feb 7, 2019, at 11:57 AM, orenpa11  wrote:
> 
> Hi,
> If I would like to write a code in pretty big what is the first line that 
> need to be written ?
> Can I use  #lang  ?
> 
> Thanks,
> Or
> 
> 
> 
> -- 
> 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] Some concern about ChezScheme...

2019-02-06 Thread Matthias Felleisen


My recollection is that Kent taught with this approach because it simplified 
homeworks for students and graders and I encouraged him to write it up for the 
“education pearl” section that I launched for JFP in ’03. It took several years 
to collect the papers and get them written and publish them (back then, 
journals still had “print queues”) — Matthias




> On Feb 6, 2019, at 2:22 PM, 'Paulo Matos' via Racket Users 
>  wrote:
> 
> Thanks for the references. That really useful. 
> 
> Interestingly according to Matt these ideas were already floating around at 
> his uni as early as 98?
> 
> On 6 February 2019 18:50:21 CET, Matthias Felleisen  
> wrote:
> 
> 
>> On Feb 6, 2019, at 12:30 PM, 'Paulo Matos' via Racket Users 
>>  wrote:
>> 
>> I was quite surprised to read these nanopass ideas have been around for
>> so long.
> 
> 
> 1. The educational idea came first: 
> 
> A Nanopass framework for compiler education. • Volume 15, Issue 5 • September 
> 2005 , pp. 653-667
> 
> https://www.cambridge.org/core/journals/journal-of-functional-programming/article/educational-pearl-a-nanopass-framework-for-compiler-education/1E378B9B451270AF6A155FA0C21C04A3
> 
> 2. The experience report of applying the idea to a commercial compiler came 
> about 10 years later: 
> 
> A Nanopass framework for commercial compiler development. ICFP ’13 , pp 
> 343-350
> 
> https://dl.acm.org/citation.cfm?id=2500618
> 
> — Matthias
> 
> 
> 
> 
> --
> Paulo Matos
> 
> -- 
> 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] Some concern about ChezScheme...

2019-02-06 Thread Matthias Felleisen


> On Feb 6, 2019, at 12:30 PM, 'Paulo Matos' via Racket Users 
>  wrote:
> 
> I was quite surprised to read these nanopass ideas have been around for
> so long.


1. The educational idea came first: 

A Nanopass framework for compiler education. • Volume 15, Issue 5 • September 
2005 , pp. 653-667

https://www.cambridge.org/core/journals/journal-of-functional-programming/article/educational-pearl-a-nanopass-framework-for-compiler-education/1E378B9B451270AF6A155FA0C21C04A3

2. The experience report of applying the idea to a commercial compiler came 
about 10 years later: 

A Nanopass framework for commercial compiler development. ICFP ’13 , pp 343-350

https://dl.acm.org/citation.cfm?id=2500618 


— Matthias



-- 
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-04 Thread Matthias Felleisen


Great. Let’s include this link in Alex’s write up as an example of a concrete 
comparison. Even if such simple benchmarks don’t reflect daily, end-to-end 
programs, they can help people by dispelling some prejudices. Thanks — Matthias



> On Feb 4, 2019, at 11:56 AM, Gustavo Massaccesi  wrote:
> 
> For some reason, the Racket vs Python performance is a question that arise 
> from time to time in Hacke News (like 2 or 3 times per year). Last time I 
> asked if it was possible to add a direct comparison in The Computer Language 
> Benchmarks Game and the owner/maintainer added that page. The results are in 
> https://benchmarksgame-team.pages.debian.net/benchmarksgame/faster/racket-python3.html
>  [Standard disclaimer: The results change from program to program, so take 
> this comparison only as a guide.]
> 
> A short version of the results is that:
> * in 6 of the programs Racket is much faster
> * in 1 of the programs Racket is faster
> * in 2 of the programs there is almost a tie
> * in 1 of the programs Racket is slower
> 
> Some programs in Racket need parallelization, so the results may improve in 
> the future. [I didn't look too carefully at the programs in Python.]
> 
> My unofficial takeaway, not completely backed by the benchmarks, is that
> * For numeric programs Racket is (may be) 5 to 20 times faster than Python
> * For programs with too many stings and hashes, the speed is almost the same.
> 
> 
> 
> Also, there was an old thread about translating the classic Norvig's spelling 
> correction from Python to Racket, without changing the structure of the 
> implementation too much and using idiomatic code.
> https://groups.google.com/forum/#!topic/racket-users/u0Ua1kTUSKw After a few 
> attempts, the final version in Racket was a 30% slower. I didn't follow this 
> too much after the discussion, so I don't know if there is a smaller or 
> bigger difference using the current versions. (Also, I think we never tried 
> to make is fast as possible, with the same algorithms, but changing the 
> implementation as much as it was necessary.)
> 
> Gustavo
> 
> On Sun, Feb 3, 2019 at 7:38 PM Matthias Felleisen  
> wrote:
> 
> Agreed! 
> 
> 
> 
>> On Feb 3, 2019, at 4:43 PM, Robby Findler  
>> wrote:
>> 
>> It seems like a great addition to the performance section of the guide. 
>> 
>> Robby 
>> 
>> On Sun, Feb 3, 2019 at 3:35 PM Matthias Felleisen  
>> wrote:
>> 
>> 1. I think this is a great start for a generic introduction to data 
>> structures. Someone should integrate Jens’s short table: 
>> 
>>  
>> https://stackoverflow.com/questions/27584416/in-racket-what-is-the-advantage-of-lists-over-vectors/27589146#27589146
>>  
>> 
>> 
>> 2. I think language-to-language documents serve a different role, but your 
>> document could be cited from there. 
>> 
>> The point of say “From Python to Racket” would be to show how comprehensions 
>> translate or how classes work 1-1. And yes, it would also explain that 
>> Racket calls something a list that does __not___ at all correspond to a 
>> list. 
>> 
>> The corresponding Java write-up would be quite different again. In that 
>> case, we would be dealing with people who might not know more than classes 
>> and methods. But they might actually know proper design and might know that 
>> it calls for recursion (hidden in classes and interfaces). In Racket, that 
>> works even better than in Java. Plus it would need to say something brief 
>> about types. 
>> 
>> And R would be an entirely different story. 
>> 
>> — Matthias
>> 
>> 
>> 
>> 
>> 
>>> On Feb 2, 2019, at 11:37 PM, Alex Harsanyi  wrote:
>>> 
>>> 
>>> I put together some notes about available data structures in Racket, with 
>>> some performance considerations.  It needs more work, but perhaps it can be 
>>> used as a starting point and it can be added to the Racket wiki, if/when 
>>> others consider it adequate:
>>> 
>>> https://gist.github.com/alex-hhh/3cc5690a7f9c74543dab6c11344e6202
>>> 
>>> I didn't write a "Python to Racket" guide, because I don't really know 
>>> enough about Python to write such a document, and I also think that a more 
>>> generic document is simpler to maintain and can be used by people who come 
>>> from other languages as well.
>>> 
>>> I also tried to keep the document short, the aim being to provide a 
>>> competent programmer who is new to Racket with a 5 minute overview to its 
>>> data structures and some links to the starting po

Re: [racket-users] Python's append vs Racket's append and helping novices understand the implications

2019-02-03 Thread Matthias Felleisen

Agreed! 



> On Feb 3, 2019, at 4:43 PM, Robby Findler  wrote:
> 
> It seems like a great addition to the performance section of the guide. 
> 
> Robby 
> 
> On Sun, Feb 3, 2019 at 3:35 PM Matthias Felleisen  <mailto:matth...@felleisen.org>> wrote:
> 
> 1. I think this is a great start for a generic introduction to data 
> structures. Someone should integrate Jens’s short table: 
> 
>  
> https://stackoverflow.com/questions/27584416/in-racket-what-is-the-advantage-of-lists-over-vectors/27589146#27589146
>  
> <https://stackoverflow.com/questions/27584416/in-racket-what-is-the-advantage-of-lists-over-vectors/27589146#27589146>
>  
> 
> 
> 2. I think language-to-language documents serve a different role, but your 
> document could be cited from there. 
> 
> The point of say “From Python to Racket” would be to show how comprehensions 
> translate or how classes work 1-1. And yes, it would also explain that Racket 
> calls something a list that does __not___ at all correspond to a list. 
> 
> The corresponding Java write-up would be quite different again. In that case, 
> we would be dealing with people who might not know more than classes and 
> methods. But they might actually know proper design and might know that it 
> calls for recursion (hidden in classes and interfaces). In Racket, that works 
> even better than in Java. Plus it would need to say something brief about 
> types. 
> 
> And R would be an entirely different story. 
> 
> — Matthias
> 
> 
> 
> 
> 
>> On Feb 2, 2019, at 11:37 PM, Alex Harsanyi > <mailto:alexharsa...@gmail.com>> wrote:
>> 
>> 
>> I put together some notes about available data structures in Racket, with 
>> some performance considerations.  It needs more work, but perhaps it can be 
>> used as a starting point and it can be added to the Racket wiki, if/when 
>> others consider it adequate:
>> 
>> https://gist.github.com/alex-hhh/3cc5690a7f9c74543dab6c11344e6202 
>> <https://gist.github.com/alex-hhh/3cc5690a7f9c74543dab6c11344e6202>
>> 
>> I didn't write a "Python to Racket" guide, because I don't really know 
>> enough about Python to write such a document, and I also think that a more 
>> generic document is simpler to maintain and can be used by people who come 
>> from other languages as well.
>> 
>> I also tried to keep the document short, the aim being to provide a 
>> competent programmer who is new to Racket with a 5 minute overview to its 
>> data structures and some links to the starting points in the documentation.  
>> We can add things to it, but I think it is better to keep it short rather 
>> than comprehensive in this case -- after all, there is the Racket Guide and 
>> Racket Reference and these documents contain all the details.  Perhaps new 
>> documents can be added to the wiki, exploring other topics in more detail.
>> 
>> I did not mention `ralist` because (1) I have no experience with it, but 
>> more importantly (2) the package is not part of the Racket distribution and 
>> has to be installed separately.  I don't it reflects well on Racket if we 
>> tell people to install a separate package if they want an efficient 
>> container...  I have no experience with `ralist`, but if it is indeed a good 
>> data structure and it has a potentially wide usage, it should be included in 
>> the default Racket installation.
>> 
>> Alex.
>> 
>> On Sunday, February 3, 2019 at 7:00:10 AM UTC+8, 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

Re: [racket-users] Python's append vs Racket's append and helping novices understand the implications

2019-02-03 Thread Matthias Felleisen

1. I think this is a great start for a generic introduction to data structures. 
Someone should integrate Jens’s short table: 

 
https://stackoverflow.com/questions/27584416/in-racket-what-is-the-advantage-of-lists-over-vectors/27589146#27589146
 
<https://stackoverflow.com/questions/27584416/in-racket-what-is-the-advantage-of-lists-over-vectors/27589146#27589146>
 


2. I think language-to-language documents serve a different role, but your 
document could be cited from there. 

The point of say “From Python to Racket” would be to show how comprehensions 
translate or how classes work 1-1. And yes, it would also explain that Racket 
calls something a list that does __not___ at all correspond to a list. 

The corresponding Java write-up would be quite different again. In that case, 
we would be dealing with people who might not know more than classes and 
methods. But they might actually know proper design and might know that it 
calls for recursion (hidden in classes and interfaces). In Racket, that works 
even better than in Java. Plus it would need to say something brief about 
types. 

And R would be an entirely different story. 

— Matthias





> On Feb 2, 2019, at 11:37 PM, Alex Harsanyi  wrote:
> 
> 
> I put together some notes about available data structures in Racket, with 
> some performance considerations.  It needs more work, but perhaps it can be 
> used as a starting point and it can be added to the Racket wiki, if/when 
> others consider it adequate:
> 
> https://gist.github.com/alex-hhh/3cc5690a7f9c74543dab6c11344e6202
> 
> I didn't write a "Python to Racket" guide, because I don't really know enough 
> about Python to write such a document, and I also think that a more generic 
> document is simpler to maintain and can be used by people who come from other 
> languages as well.
> 
> I also tried to keep the document short, the aim being to provide a competent 
> programmer who is new to Racket with a 5 minute overview to its data 
> structures and some links to the starting points in the documentation.  We 
> can add things to it, but I think it is better to keep it short rather than 
> comprehensive in this case -- after all, there is the Racket Guide and Racket 
> Reference and these documents contain all the details.  Perhaps new documents 
> can be added to the wiki, exploring other topics in more detail.
> 
> I did not mention `ralist` because (1) I have no experience with it, but more 
> importantly (2) the package is not part of the Racket distribution and has to 
> be installed separately.  I don't it reflects well on Racket if we tell 
> people to install a separate package if they want an efficient container...  
> I have no experience with `ralist`, but if it is indeed a good data structure 
> and it has a potentially wide usage, it should be included in the default 
> Racket installation.
> 
> Alex.
> 
> On Sunday, February 3, 2019 at 7:00:10 AM UTC+8, 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 
> <mailto:racket-users+unsubscr...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout 
> <https

[racket-users] Re: From Guido to Matthias (was: Python's append vs Racket's append and helping novices understand the implications)

2019-02-03 Thread Matthias Felleisen


> On Feb 3, 2019, at 10:12 AM, Laurent  wrote:
> 
> When was that and what was the outcome of this meeting?


Nothing. It was a waste of my time. — Matthias

-- 
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: performance: Racket vs Julia

2019-02-02 Thread Matthias Felleisen


It is rare that I have to somewhat-contradict Matthew here, but so it goes. 

One of my colleagues, Jan Vitek, has studied Julia with a special focus on 
performance. As many have said, Julia is good at numerics because its compiler 
can specialize certain cases really well. More generally, it does well when a 
programmer commits to the effort of writing down performance-enhancing types. 
[1] BUT, there’s an incredible pitfall associated with this approach. If the 
programmer is a bit off with the types (not wrt correctness but wrt to 
narrowness or forgets to specify a type somewhere), the compiler still succeeds 
except that the program will be rather slow when uses certain paths [2]. So 
your performance experience with Julia could be quite varied. 

Use Racket for what you have in mind. It’s obviously the superior language :-) 

— Matthias

p.s. If there’s interest, I can dig out Jan’s draft paper. 


[1] Julia is gradually typed but it should really be considered optionally 
typed. The types are about performance, so they are more like C types than ML 
type.s 

[2] Julia’s compiler is tailor-made for an application of Vincent St-Amour’s 
dissertation research on feature-specific profiling. 

-- 
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-02 Thread Matthias Felleisen



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.


Re: [racket-users] How To Design Classes text not available?

2019-02-02 Thread Matthias Felleisen

http://felleisen.org/matthias/htdc.html 
 

[ The ccs.neu.edu  file is actually a redirect HTML file 
but that doesn’t seem to work. ]



> On Feb 2, 2019, at 3:26 PM, Justin Zamora  wrote:
> 
> I tried to download the draft of "How to Design Classes" from
> http://www.ccs.neu.edu/home/matthias/htdc.html and got a "Failed to
> load PDF document" error. Is this text still available?
> 
> Justin
> 
> -- 
> 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] Spritely awarded Samsung Stack Zero grant

2019-01-31 Thread Matthias Felleisen



Thank you for your efforts and stamina in pursuit of this goal. I hope that 
Samsung will continue to be generous to you :) 

Congrats! — Matthias





> On Jan 31, 2019, at 5:46 PM, Christopher Lemmer Webber 
>  wrote:
> 
> I've mentioned that my goal has been to advance the
> federated/decentralized social web in Racket on here before.  Here's
> some news:
> 
>  
> https://samsungnext.com/whats-next/category/podcasts/decentralization-samsung-next-stack-zero-grant-recipients/
> 
> I'm being funded for the next two years to work on this stuff!  And I'm
> planning on doing it all in Racket.
> 
> In fact, I'm at a hackathon right now kicking it off, and I'm on the
> verge of releasing the first major demo.
> 
> Anyway, there's been some conversation about
> wouldn't-it-be-nice-if-more-people-were-paid-to-do-web-dev-in-racket
> so... here's one case! :)
> 
> I hope I can use this to help raise the profile of how great Racket
> is for this kind of work!
> 
> - Chris
> 
> -- 
> 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] Re: updated Racket-on-Chez status

2019-01-31 Thread Matthias Felleisen


> On Jan 30, 2019, at 8:52 PM, Sam Tobin-Hochstadt  wrote:
> 
>> Although there are costs to TR in compile time and load time,
>> especially in a program that also has untyped components, I generally
>> would not recommend moving away from TR.
> 
> Unlike Matthew, I can be sure not to offend the creator of Typed
> Racket by saying that in some cases, contract generation can take too
> much compile time or bytecode space, or result in too big a runtime
> overhead, to be acceptable. In those cases, I recommend either using
> the `typed/racket/unsafe` library to omit contracts (and protect
> things manually) or move away from Typed Racket entirely. The places I
> know where this has been an issue are very large OO hierarchies (as in
> the `racket/gui` library) and very large data types constructed from
> many unions of many distinct structs. I'm happy to take a look at your
> code if that would be helpful.


I have no problem offending the lead TR designer and maintainer
(also thanks to Asumu, Stevie, Kent, and everyone else who designed
& implemented essential elements. The offense is to Sam alone :) 

;; - - - 

If adding Typed Racket to Unityped Racket code (I sure do like
your insistence on Dana Scott’s terminology) feels like it’s 
slowing down your code, please try the feature-specific profiler 
to determine the module boundary that imposes the cost. By 
moving this boundary (like adding another typed module) you 
might be able to get the full performance benefits of TR (there 
are some). 

Yes, we should improve FSP and document it for these cases, 
but from looking at your blog and emails, I suspect you can 
cope. This would be tremendously helpful for the continued 
TR development. 

Thanks — Matthias

-- 
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] Problem controlling macro expansion

2019-01-27 Thread Matthias Felleisen

See docs for local-expand. 


> On Jan 27, 2019, at 5:15 PM, Jonathan Simpson  wrote:
> 
> The code contained within lines-to-syntax-tree will run tests on an input 
> stream. My original plan was to have a function like run-query that would 
> execute the tests. So I'd need to quote the tests because they'd be executed 
> in an order defined by run-query.
> 
> I will look into making run-query a macro that expands into the code that 
> runs the tests. That may be easier in the long run anyway. Plus I'd like to 
> avoid eval in my runtime code.
> 
> I am curious if there is an easy way to expand lines-to-syntax-tree and then 
> quote it though. I'm having a hard time making the macro system do what I 
> want. I usually know what needs to be done, but quickly run into things that 
> I don't understand.
> 
> Thanks,
> Jonathan
> 
> On Sunday, January 27, 2019 at 4:08:54 PM UTC-5, Matthias Felleisen wrote:
> 
> Why is run-query not a macro and if it were, why would you quote 
> lines-to-syntax-tree? 
> 
> 
>> On Jan 27, 2019, at 4:06 PM, Jonathan Simpson gmail.com 
>> <http://gmail.com/>> wrote:
>> 
>> I'm having macro troubles with a DSL I'm writing. I have a macro that looks 
>> something like this:
>> 
>> (define-syntax (query stx)
>>   (let ([lines (cdr (syntax->datum stx))])
>> (define lines-syntax-tree (parse-to-tree lines))
>> (datum->syntax stx lines-syntax-tree)))
>> 
>> So something like 
>> 
>> (query ...linear series of s-expressions containing non-nested code...)
>> 
>> is transformed into (...hierarchical code in tree form...).
>> 
>> But what I really want is
>> 
>> (run-query '(...code in tree form...))
>> 
>> The code that I'd like quoted and passed to run-query has a number of macros 
>> I wrote that also need expanding. My problem is that all of my attempts to 
>> write a macro that results in run-query being passed a list of code to 
>> execute blocks the expansion of the passed code. Basically, I want to expand 
>> 'lines-syntax-tree' before I quote it and generate an expansion including 
>> run-query.
>> 
>> For instance, this obviously doesn't work:
>> 
>> (define-syntax (query stx)
>>   (let ([lines (cdr (syntax->datum stx))])
>> (define lines-syntax-tree (parse-to-tree lines))
>> (define q (list 'run-query (quote lines-syntax-tree)))
>> (datum->syntax stx q)))
>> 
>> I'm sure I'm missing something silly, but I'd appreciate any help. I should 
>> probably read https://docs.racket-lang.org/reference/syntax-model.html 
>> <https://docs.racket-lang.org/reference/syntax-model.html>, but it is going 
>> to take me some time to grok that.
>> 
>> Thanks,
>> Jonathan
>> 
>> 
>> -- 
>> 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...@ <>googlegroups.com <http://googlegroups.com/>.
>> For more options, visit https://groups.google.com/d/optout 
>> <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 
> <mailto:racket-users+unsubscr...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout 
> <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] Problem controlling macro expansion

2019-01-27 Thread Matthias Felleisen

Why is run-query not a macro and if it were, why would you quote 
lines-to-syntax-tree? 


> On Jan 27, 2019, at 4:06 PM, Jonathan Simpson  wrote:
> 
> I'm having macro troubles with a DSL I'm writing. I have a macro that looks 
> something like this:
> 
> (define-syntax (query stx)
>   (let ([lines (cdr (syntax->datum stx))])
> (define lines-syntax-tree (parse-to-tree lines))
> (datum->syntax stx lines-syntax-tree)))
> 
> So something like 
> 
> (query ...linear series of s-expressions containing non-nested code...)
> 
> is transformed into (...hierarchical code in tree form...).
> 
> But what I really want is
> 
> (run-query '(...code in tree form...))
> 
> The code that I'd like quoted and passed to run-query has a number of macros 
> I wrote that also need expanding. My problem is that all of my attempts to 
> write a macro that results in run-query being passed a list of code to 
> execute blocks the expansion of the passed code. Basically, I want to expand 
> 'lines-syntax-tree' before I quote it and generate an expansion including 
> run-query.
> 
> For instance, this obviously doesn't work:
> 
> (define-syntax (query stx)
>   (let ([lines (cdr (syntax->datum stx))])
> (define lines-syntax-tree (parse-to-tree lines))
> (define q (list 'run-query (quote lines-syntax-tree)))
> (datum->syntax stx q)))
> 
> I'm sure I'm missing something silly, but I'd appreciate any help. I should 
> probably read https://docs.racket-lang.org/reference/syntax-model.html, but 
> it is going to take me some time to grok that.
> 
> Thanks,
> Jonathan
> 
> 
> -- 
> 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] snake game

2019-01-26 Thread Matthias Felleisen

This is a working PB program: 

(require test-engine/racket-tests)
(require 2htdp/image)
(require 2htdp/universe)

(big-bang 100
  (to-draw (lambda (x) (circle (+ x 1) 'solid 'red)))
  (on-tick sub1)
  (stop-when zero?))

(test)


Now please do the rest of your homework yourself. 


> On Jan 26, 2019, at 2:55 PM, orenpa11  wrote:
> 
> Hi Matthias ,
> I am sorry but I still did get it.
> should I import the snake file that was written in "Beginning Student with 
> List Abbreviations"  and the code will be chnaged to  pretty big ?
> or only the "check-expect" is been chnaged from  "Beginning Student with List 
> Abbreviations"  to  pretty big ?
> Does Pretty Big has  drawing functions ?
> 
> Thanks,
> Or
> 
> On Friday, January 25, 2019 at 5:33:50 PM UTC+2, Matthias Felleisen wrote:
> 
> See below. I gave precise instructions. 
> 
> 
> > On Jan 25, 2019, at 10:27 AM, orenpa11 > 
> > wrote: 
> > 
> > OK, 
> > Got it , but how can I import the code of the snake program that was 
> > written in "Beginning Student with List Abbreviations"  and chnage it to  
> > pretty big ? 
> >   
> > 
> > On Friday, January 25, 2019 at 4:08:40 PM UTC+2, Robby Findler wrote: 
> > You've opened the right dialog. Now type "test-" into it. You should 
> > see the file appear. Click on it. 
> > 
> > Robby 
> > 
> > On Fri, Jan 25, 2019 at 7:53 AM orenpa11 > wrote: 
> > > 
> > > Hi, 
> > > Sorry but I did not get it. 
> > > should I add the path to the rkt file or add the code ? 
> > > 
> > > Thanks, 
> > > Or 
> > > 
> > > On Friday, January 25, 2019 at 1:39:12 PM UTC+2, Matthias Felleisen 
> > > wrote: 
> > >> 
> > >> 
> > >> DrRacket -> File -> Open Require Path -> enter test- -> use mouse 
> > >> 
> > >> 
> > >> On Jan 24, 2019, at 11:11 PM, orenpa11 > wrote: 
> > >> 
> > >> Hi 
> > >> where can I find the  test-engine ? 
> > >> I would like to copy the code  and  "play" with it. 
> > >> So I can understand it better . 
> > >> just copying the code is not helpful because I need to understand it. 
> > >> 
> > >> Thanks, 
> > >> Or 
> > >> 
> > >> On Thursday, January 24, 2019 at 11:54:34 PM UTC+2, Matthias Felleisen 
> > >> wrote: 
> > >>> 
> > >>> 
> > >>> Yes there is. Use (require test-engine/racket-tests) 
> > >>> at the top and (test) at the bottom. 
> > >>> 
> > >>> But it sounds like you’re copying and pasting homework 
> > >>> solutions. Hmph. 
> > >>> 
> > >>> 
> > >>> 
> > >>> 
> > >>> > On Jan 24, 2019, at 3:44 PM, orenpa11 > wrote: 
> > >>> > 
> > >>> > Hi Matthias , 
> > >>> > Unfortunately I need to write the project in pretty big language. 
> > >>> > The game is not written in pretty big language as far as I know. 
> > >>> > I thought that can copy andycode that was written in any language in 
> > >>> > racket to pretty big. 
> > >>> > Is there a way to transfer code that was written in  "Beginning 
> > >>> > Student with List Abbreviations" to pretty big ? 
> > >>> > 
> > >>> > Thanks, 
> > >>> > Or 
> > >>> > 
> > >>> > 
> > >>> > 
> > >>> > 
> > >>> > On Thursday, January 24, 2019 at 9:19:14 PM UTC+2, Matthias Felleisen 
> > >>> > wrote: 
> > >>> > 
> > >>> > 
> > >>> > Where did you find the snake game? 
> > >>> > Where did it say it’s written in Pretty Big? 
> > >>> > 
> > >>> > We have not used Pretty Big in over a decade in education, 
> > >>> > neither does anyone in the Racket edu community proper. 
> > >>> > 
> > >>> > This community supports people readily wth answers, but 
> > >>> > we need to know what you know. 
> > >>> > 
> > >>> > — Matthias 
> > >>> > 
> > >>> > 
> > >>> > 
> > >>> > 
> > >>> > > On Jan 24, 2019, at 12:56 PM, orenpa11 > wrote: 
> > >>&g

Re: [racket-users] Collections and data structures wishlist?

2019-01-26 Thread Matthias Felleisen

> On Jan 26, 2019, at 9:03 AM, Sorawee Porncharoenwase 
>  wrote:
> 
> Matthias, where can I find this "History of Clojure"? I searched for "It is 
> better to have 100 transducers ..." and found no result (besides this very 
> thread). I also searched for "History of Clojure" and only found this tweet 
>  from Rich Hickey 
> in Nov 2018, and it seems he was still writing it back then. Is it available 
> for public to view now?
> 


Unpublished notes. But I believe he said something like that during his 
StrangeLoop presentation of transducers in Clojure. 


> If we take an argument that we can encode a tuple with a list and get all 
> benefits from list operations, why don't we (define-values (bool/c true 
> false) (values int/c 1 0))? Why don't we (Church) encode everything to 
> lambdas?


Functions are infinite data, lists are finite. You need to develop good taste 
for good compromises. 

I am the one who pushed PLT Scheme/Racket into the static corner (e.g., 
structs). But the place in the middle is where the sweet spot is. 

— Matthias, radical centrist with nuanced opinions often stated in provocative 
ways :) 

-- 
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] Collections and data structures wishlist?

2019-01-26 Thread Matthias Felleisen



> On Jan 26, 2019, at 8:31 AM, Hendrik Boom  wrote:
> 
> On Fri, Jan 25, 2019 at 07:50:56PM -0500, Matthias Felleisen wrote:
>> 
>> Yes. See Clojure history. — Matthias
> 
> Given the amount of text you have quoted, it's not clear what you are 
> saying yes to.


Hickey: "we tweak Perlis one final time - "It is best to have 100 functions 
operate on NO data structure”.” 

[[ He means to have 100 transducers on Interfaces, instead of 10 x 10 functions 
on concrete data structures. ]]

-- 
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] Collections and data structures wishlist?

2019-01-25 Thread Matthias Felleisen

Yes. See Clojure history. — Matthias



> On Jan 25, 2019, at 4:21 PM, Jack Firth  wrote:
> 
> I don't intend to make these operations impossible or even difficult. One of 
> the other things on my wishlist is a transducers library, which would IMO be 
> a good fit for a lot of the logic that Racket currently provides as 
> list-processing functions. So if you want to process tuples as generalized 
> streams of values, you'd use transducers on them. But if you want to process 
> tuples as tuples, you'd use tuple-processing functions. I think mapping and 
> filtering fit the first category more than the second. This kind of divide 
> makes it much easier to support a wide array of data structures without 
> copying the entire list processing API for each one.
> 
> On Fri, Jan 25, 2019 at 12:51 PM Matthias Felleisen  <mailto:matth...@felleisen.org>> wrote:
> 
> > On Jan 25, 2019, at 3:46 PM, Thomas F. Burdick  > <mailto:tho...@burdick.fr>> wrote:
> > 
> > 
> > 
> > On January 25, 2019 8:33:09 PM GMT+01:00, Jack Firth  > <mailto:jackhfi...@gmail.com>> wrote:
> >> 
> >> Due to the kind of data that would go in tuples - namely, a fixed-sized
> >> heterogeneous collection of values - a function probably *shouldn't*
> >> use
> >> map and filter to process tuples. A program that calls filter on an
> >> x-y-z
> >> coordinate tuple is likely incorrect and not what the programmer
> >> intended.
> > 
> > Funny you should pick that as an example. I work in a CAD environment where 
> > points are two-item lists, and polygon outlines are lists of points. You'd 
> > be surprised how often it's useful to use ordinary list functions on points.
> 
> 
> That’s precisely the kind of programming I had in mind. Racket is one of the 
> few languages where you can eat your cake and have it anyways. Why take away 
> that strength?

-- 
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] Collections and data structures wishlist?

2019-01-25 Thread Matthias Felleisen


> On Jan 25, 2019, at 3:46 PM, Thomas F. Burdick  wrote:
> 
> 
> 
> On January 25, 2019 8:33:09 PM GMT+01:00, Jack Firth  
> wrote:
>> 
>> Due to the kind of data that would go in tuples - namely, a fixed-sized
>> heterogeneous collection of values - a function probably *shouldn't*
>> use
>> map and filter to process tuples. A program that calls filter on an
>> x-y-z
>> coordinate tuple is likely incorrect and not what the programmer
>> intended.
> 
> Funny you should pick that as an example. I work in a CAD environment where 
> points are two-item lists, and polygon outlines are lists of points. You'd be 
> surprised how often it's useful to use ordinary list functions on points.


That’s precisely the kind of programming I had in mind. Racket is one of the 
few languages where you can eat your cake and have it anyways. Why take away 
that strength? 

-- 
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] snake game

2019-01-25 Thread Matthias Felleisen


See below. I gave precise instructions. 


> On Jan 25, 2019, at 10:27 AM, orenpa11  wrote:
> 
> OK,
> Got it , but how can I import the code of the snake program that was written 
> in "Beginning Student with List Abbreviations"  and chnage it to  pretty big ?
>  
> 
> On Friday, January 25, 2019 at 4:08:40 PM UTC+2, Robby Findler wrote:
> You've opened the right dialog. Now type "test-" into it. You should 
> see the file appear. Click on it. 
> 
> Robby 
> 
> On Fri, Jan 25, 2019 at 7:53 AM orenpa11  wrote: 
> > 
> > Hi, 
> > Sorry but I did not get it. 
> > should I add the path to the rkt file or add the code ? 
> > 
> > Thanks, 
> > Or 
> > 
> > On Friday, January 25, 2019 at 1:39:12 PM UTC+2, Matthias Felleisen wrote: 
> >> 
> >> 
> >> DrRacket -> File -> Open Require Path -> enter test- -> use mouse 
> >> 
> >> 
> >> On Jan 24, 2019, at 11:11 PM, orenpa11  wrote: 
> >> 
> >> Hi 
> >> where can I find the  test-engine ? 
> >> I would like to copy the code  and  "play" with it. 
> >> So I can understand it better . 
> >> just copying the code is not helpful because I need to understand it. 
> >> 
> >> Thanks, 
> >> Or 
> >> 
> >> On Thursday, January 24, 2019 at 11:54:34 PM UTC+2, Matthias Felleisen 
> >> wrote: 
> >>> 
> >>> 
> >>> Yes there is. Use (require test-engine/racket-tests) 
> >>> at the top and (test) at the bottom. 
> >>> 
> >>> But it sounds like you’re copying and pasting homework 
> >>> solutions. Hmph. 
> >>> 
> >>> 
> >>> 
> >>> 
> >>> > On Jan 24, 2019, at 3:44 PM, orenpa11  wrote: 
> >>> > 
> >>> > Hi Matthias , 
> >>> > Unfortunately I need to write the project in pretty big language. 
> >>> > The game is not written in pretty big language as far as I know. 
> >>> > I thought that can copy andycode that was written in any language in 
> >>> > racket to pretty big. 
> >>> > Is there a way to transfer code that was written in  "Beginning Student 
> >>> > with List Abbreviations" to pretty big ? 
> >>> > 
> >>> > Thanks, 
> >>> > Or 
> >>> > 
> >>> > 
> >>> > 
> >>> > 
> >>> > On Thursday, January 24, 2019 at 9:19:14 PM UTC+2, Matthias Felleisen 
> >>> > wrote: 
> >>> > 
> >>> > 
> >>> > Where did you find the snake game? 
> >>> > Where did it say it’s written in Pretty Big? 
> >>> > 
> >>> > We have not used Pretty Big in over a decade in education, 
> >>> > neither does anyone in the Racket edu community proper. 
> >>> > 
> >>> > This community supports people readily wth answers, but 
> >>> > we need to know what you know. 
> >>> > 
> >>> > — Matthias 
> >>> > 
> >>> > 
> >>> > 
> >>> > 
> >>> > > On Jan 24, 2019, at 12:56 PM, orenpa11  wrote: 
> >>> > > 
> >>> > > Hi 
> >>> > > I need to create a project in pertty big . 
> >>> > > why this code is not been supported ? 
> >>> > > 
> >>> > > Thanks, 
> >>> > > Or 
> >>> > > 
> >>> > > On Thursday, January 24, 2019 at 3:29:11 PM UTC+2, Kieron Hardy 
> >>> > > wrote: 
> >>> > > The language you should be using is "Beginning Student with List 
> >>> > > Abbreviations". 
> >>> > > 
> >>> > > On Jan 24, 2019, at 4:33 AM, orenpa11  wrote: 
> >>> > > 
> >>> > >> Hi, 
> >>> > >> when I removed the line 
> >>> > >> #reader(lib "htdp-beginner-abbr-reader.ss" "lang")((modname 
> >>> > >> snake-full) (read-case-sensitive #t) (teachpacks ()) (htdp-settings 
> >>> > >> #(#t constructor repeating-decimal #f #t none #f ( 
> >>> > >> 
> >>> > >> And changed the  language to pretty big. 
> >>> > >> I recived this error: 
> >>> > >> Welcome to DrRacket, version 7.1 [3m]. 
> >>> > >> Lang

Re: [racket-users] snake game

2019-01-25 Thread Matthias Felleisen

DrRacket -> File -> Open Require Path -> enter test- -> use mouse 


> On Jan 24, 2019, at 11:11 PM, orenpa11  wrote:
> 
> Hi
> where can I find the  test-engine ?
> I would like to copy the code  and  "play" with it.
> So I can understand it better .
> just copying the code is not helpful because I need to understand it.
> 
> Thanks,
> Or
> 
> On Thursday, January 24, 2019 at 11:54:34 PM UTC+2, Matthias Felleisen wrote:
> 
> Yes there is. Use (require test-engine/racket-tests) 
> at the top and (test) at the bottom. 
> 
> But it sounds like you’re copying and pasting homework 
> solutions. Hmph. 
> 
> 
> 
> 
> > On Jan 24, 2019, at 3:44 PM, orenpa11 gmail.com 
> > <http://gmail.com/>> wrote: 
> > 
> > Hi Matthias , 
> > Unfortunately I need to write the project in pretty big language. 
> > The game is not written in pretty big language as far as I know. 
> > I thought that can copy andycode that was written in any language in racket 
> > to pretty big. 
> > Is there a way to transfer code that was written in  "Beginning Student 
> > with List Abbreviations" to pretty big ? 
> > 
> > Thanks, 
> > Or 
> > 
> > 
> > 
> > 
> > On Thursday, January 24, 2019 at 9:19:14 PM UTC+2, Matthias Felleisen 
> > wrote: 
> > 
> > 
> > Where did you find the snake game? 
> > Where did it say it’s written in Pretty Big? 
> > 
> > We have not used Pretty Big in over a decade in education, 
> > neither does anyone in the Racket edu community proper. 
> > 
> > This community supports people readily wth answers, but 
> > we need to know what you know. 
> > 
> > — Matthias 
> > 
> > 
> > 
> > 
> > > On Jan 24, 2019, at 12:56 PM, orenpa11 > wrote: 
> > > 
> > > Hi 
> > > I need to create a project in pertty big . 
> > > why this code is not been supported ? 
> > > 
> > > Thanks, 
> > > Or 
> > > 
> > > On Thursday, January 24, 2019 at 3:29:11 PM UTC+2, Kieron Hardy wrote: 
> > > The language you should be using is "Beginning Student with List 
> > > Abbreviations". 
> > > 
> > > On Jan 24, 2019, at 4:33 AM, orenpa11 gmail.com 
> > > <http://gmail.com/>> wrote: 
> > > 
> > >> Hi, 
> > >> when I removed the line 
> > >> #reader(lib "htdp-beginner-abbr-reader.ss" "lang")((modname snake-full) 
> > >> (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor 
> > >> repeating-decimal #f #t none #f ( 
> > >> 
> > >> And changed the  language to pretty big. 
> > >> I recived this error: 
> > >> Welcome to DrRacket, version 7.1 [3m]. 
> > >> Language: Pretty Big; memory limit: 128 MB. 
> > >> . . check-expect: undefined; 
> > >>  cannot reference an identifier before its definition 
> > >> 
> > >> Any idea ? 
> > >> 
> > >> Thanks, 
> > >> Or 
> > >> 
> > >> 
> > >> 
> > >> 
> > >> 
> > >> On Wednesday, January 23, 2019 at 10:49:01 PM UTC+2, Kieron Hardy wrote: 
> > >> It seems the metadata lines added by DrRacket (mentioned by John) are 
> > >> processed when the a source file is loaded into DrRacket (via the menu 
> > >> option File/Open), but are not processed if the source code is directly 
> > >> copied (e.g. from a browser window) into a DrRacket window and then 
> > >> executed with the 'Run' button. 
> > >> 
> > >> The metadata includes a #reader directive, e.g.: 
> > >> (#reader(lib "htdp-beginner-abbr-reader.ss" "lang")((modname snake-full) 
> > >> ...) 
> > >> 
> > >> This reader directive appears to be silently ignored by DrRacket when 
> > >> the source is 'Run', even though DrRacket shows "#reader" in red (as 
> > >> when an error is detected). The actions taken by DrRacket when 'Run' is 
> > >> pressed seem to depend on the settings in effect when the code is 
> > >> executed, which could be nothing, or throwing a confusing error. 
> > >> 
> > >> The solution for the original poster's issue is as John directs; remove 
> > >> the metadata (i.e. #reader directive) and manually set the language. 
> > >> 
> > >> However, I feel that DrRacket should recognize and act on (and per

Re: [racket-users] snake game

2019-01-24 Thread Matthias Felleisen


Yes there is. Use (require test-engine/racket-tests)
at the top and (test) at the bottom. 

But it sounds like you’re copying and pasting homework 
solutions. Hmph. 




> On Jan 24, 2019, at 3:44 PM, orenpa11  wrote:
> 
> Hi Matthias ,
> Unfortunately I need to write the project in pretty big language.
> The game is not written in pretty big language as far as I know.
> I thought that can copy andycode that was written in any language in racket 
> to pretty big.
> Is there a way to transfer code that was written in  "Beginning Student with 
> List Abbreviations" to pretty big ?
> 
> Thanks,
> Or
> 
> 
> 
> 
> On Thursday, January 24, 2019 at 9:19:14 PM UTC+2, Matthias Felleisen wrote:
> 
> 
> Where did you find the snake game? 
> Where did it say it’s written in Pretty Big? 
> 
> We have not used Pretty Big in over a decade in education, 
> neither does anyone in the Racket edu community proper. 
> 
> This community supports people readily wth answers, but 
> we need to know what you know. 
> 
> — Matthias 
> 
> 
> 
> 
> > On Jan 24, 2019, at 12:56 PM, orenpa11  wrote: 
> > 
> > Hi 
> > I need to create a project in pertty big . 
> > why this code is not been supported ? 
> > 
> > Thanks, 
> > Or 
> > 
> > On Thursday, January 24, 2019 at 3:29:11 PM UTC+2, Kieron Hardy wrote: 
> > The language you should be using is "Beginning Student with List 
> > Abbreviations". 
> > 
> > On Jan 24, 2019, at 4:33 AM, orenpa11  wrote: 
> > 
> >> Hi, 
> >> when I removed the line 
> >> #reader(lib "htdp-beginner-abbr-reader.ss" "lang")((modname snake-full) 
> >> (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor 
> >> repeating-decimal #f #t none #f ( 
> >> 
> >> And changed the  language to pretty big. 
> >> I recived this error: 
> >> Welcome to DrRacket, version 7.1 [3m]. 
> >> Language: Pretty Big; memory limit: 128 MB. 
> >> . . check-expect: undefined; 
> >>  cannot reference an identifier before its definition 
> >> 
> >> Any idea ? 
> >> 
> >> Thanks, 
> >> Or 
> >> 
> >> 
> >> 
> >> 
> >> 
> >> On Wednesday, January 23, 2019 at 10:49:01 PM UTC+2, Kieron Hardy wrote: 
> >> It seems the metadata lines added by DrRacket (mentioned by John) are 
> >> processed when the a source file is loaded into DrRacket (via the menu 
> >> option File/Open), but are not processed if the source code is directly 
> >> copied (e.g. from a browser window) into a DrRacket window and then 
> >> executed with the 'Run' button. 
> >> 
> >> The metadata includes a #reader directive, e.g.: 
> >> (#reader(lib "htdp-beginner-abbr-reader.ss" "lang")((modname snake-full) 
> >> ...) 
> >> 
> >> This reader directive appears to be silently ignored by DrRacket when the 
> >> source is 'Run', even though DrRacket shows "#reader" in red (as when an 
> >> error is detected). The actions taken by DrRacket when 'Run' is pressed 
> >> seem to depend on the settings in effect when the code is executed, which 
> >> could be nothing, or throwing a confusing error. 
> >> 
> >> The solution for the original poster's issue is as John directs; remove 
> >> the metadata (i.e. #reader directive) and manually set the language. 
> >> 
> >> However, I feel that DrRacket should recognize and act on (and perhaps 
> >> also remove/hide from view) the metadata if the metadata occurs as from a 
> >> copy/paste directly into a DrRacket window (e.g. as from a URL). The 
> >> current behaviour is, I think, a bug and a trap (perhaps showstopping) for 
> >> a new user experimenting with Racket. 
> >> 
> >> Note that the Racket executable seems to process the metadata properly, 
> >> understanding the language to use, etc.. so that the code behaves as 
> >> intended. 
> >> 
> >> On Wed, Jan 23, 2019 at 12:32 PM K H  wrote: 
> >> Hello Or, 
> >> 
> >> The language is not "Pretty Big". 
> >> 
> >> You should be using "Beginning Student with List Abbreviations". 
> >> 
> >> The DrRacket metadata lines referred to by John set the correct language. 
> >> In your case you must have changed the language somehow. Or perhaps the 
> >> file needs to be saved before the metadata is acted upon. 
> >> 
> >> 

Re: [racket-users] Collections and data structures wishlist?

2019-01-24 Thread Matthias Felleisen


(define tuple/c list/c) 

The key to list/c and listof is that the code inside of 
functions contracted with either of them can use map 
and filter and everything else to process the arguments. 



> On Jan 24, 2019, at 8:33 AM, Gustavo Massaccesi  wrote:
> 
> I also like the idea of a contract like "tuple/c", perhaps with a more 
> rackety name.
> 
> Gustavo
> 
> On Wed, Jan 23, 2019 at 12:02 PM Greg Hendershott  
> wrote:
> >> - A separation between using lists as homogeneous collections and using 
> >> lists as fixed-size tuples. So there'd be a separate `tuple?` data type 
> >> that's structurally equivalent to a list but meant to be used differently. 
> >> For example, `(list/c number?)` would mean a list of many numbers, but 
> >> `(tuple/c number?)` would mean a tuple of size 1 containing a number.
> >
> > "It is better to have 100 functions operate on one data structure than 10 
> > functions on 10 data structures.” 
> > http://www.cs.yale.edu/homes/perlis-alan/quotes.html
> > "It is better to have 100 transducers operate on one data structure 
> > interface than 10 functions on 10 data structures.” Rich Hickey, History of 
> > Clojure
> 
> Well also, I thought `list/c` already means "tuple"?
> 
> (listof number?) is a list of many numbers.
> (list/c number?) is a list of one number.
> 
> 
> I think it's within the Racket spirit to make a little #lang for
> certain audiences or projects. At some org, "tuple/c" might be a
> helpful alias. Or, for some other team, it's not, and in fact even
> "list/c" is redefined to raise an error, "Please use structs instead
> of ad hoc tuples."
> 
> -- 
> 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] snake game

2019-01-24 Thread Matthias Felleisen



Where did you find the snake game? 
Where did it say it’s written in Pretty Big? 

We have not used Pretty Big in over a decade in education, 
neither does anyone in the Racket edu community proper. 

This community supports people readily wth answers, but 
we need to know what you know. 

— Matthias




> On Jan 24, 2019, at 12:56 PM, orenpa11  wrote:
> 
> Hi
> I need to create a project in pertty big .
> why this code is not been supported ?
> 
> Thanks,
> Or
> 
> On Thursday, January 24, 2019 at 3:29:11 PM UTC+2, Kieron Hardy wrote:
> The language you should be using is "Beginning Student with List 
> Abbreviations".
> 
> On Jan 24, 2019, at 4:33 AM, orenpa11  wrote:
> 
>> Hi,
>> when I removed the line
>> #reader(lib "htdp-beginner-abbr-reader.ss" "lang")((modname snake-full) 
>> (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor 
>> repeating-decimal #f #t none #f (
>> 
>> And changed the  language to pretty big.
>> I recived this error:
>> Welcome to DrRacket, version 7.1 [3m].
>> Language: Pretty Big; memory limit: 128 MB.
>> . . check-expect: undefined;
>>  cannot reference an identifier before its definition
>> 
>> Any idea ?
>> 
>> Thanks,
>> Or
>> 
>> 
>> 
>> 
>> 
>> On Wednesday, January 23, 2019 at 10:49:01 PM UTC+2, Kieron Hardy wrote:
>> It seems the metadata lines added by DrRacket (mentioned by John) are 
>> processed when the a source file is loaded into DrRacket (via the menu 
>> option File/Open), but are not processed if the source code is directly 
>> copied (e.g. from a browser window) into a DrRacket window and then executed 
>> with the 'Run' button.
>> 
>> The metadata includes a #reader directive, e.g.:
>> (#reader(lib "htdp-beginner-abbr-reader.ss" "lang")((modname snake-full) 
>> ...) 
>> 
>> This reader directive appears to be silently ignored by DrRacket when the 
>> source is 'Run', even though DrRacket shows "#reader" in red (as when an 
>> error is detected). The actions taken by DrRacket when 'Run' is pressed seem 
>> to depend on the settings in effect when the code is executed, which could 
>> be nothing, or throwing a confusing error. 
>> 
>> The solution for the original poster's issue is as John directs; remove the 
>> metadata (i.e. #reader directive) and manually set the language.
>> 
>> However, I feel that DrRacket should recognize and act on (and perhaps also 
>> remove/hide from view) the metadata if the metadata occurs as from a 
>> copy/paste directly into a DrRacket window (e.g. as from a URL). The current 
>> behaviour is, I think, a bug and a trap (perhaps showstopping) for a new 
>> user experimenting with Racket. 
>> 
>> Note that the Racket executable seems to process the metadata properly, 
>> understanding the language to use, etc.. so that the code behaves as 
>> intended.
>> 
>> On Wed, Jan 23, 2019 at 12:32 PM K H  wrote:
>> Hello Or,
>> 
>> The language is not "Pretty Big".
>> 
>> You should be using "Beginning Student with List Abbreviations".
>> 
>> The DrRacket metadata lines referred to by John set the correct language. In 
>> your case you must have changed the language somehow. Or perhaps the file 
>> needs to be saved before the metadata is acted upon.
>> 
>> HTH,
>> 
>> Kieron.
>> 
>> 
>> On Wed, Jan 23, 2019 at 12:17 PM 'John Clements' via Racket Users 
>>  wrote:
>> Interesting problem; your screenshot shows header text that should not 
>> appear in the window, which suggests to me that you copied and pasted the 
>> text from somewhere else into a buffer where the language level was already 
>> set. It looks to me like you should do the following:
>> 
>> 1) Delete the first three lines of the file.
>> 2) Set the language level to “beginner with list abbreviations”.
>> 3) Click “run”
>> 
>> John Clements
>> 
>> > On Jan 23, 2019, at 10:44 AM, orenpa11  wrote:
>> > 
>> > Hi David,
>> > Thanks for your swift response ,I simply do not know how to run this 
>> > program.
>> > I thought that when I press the run button I should see the snake GUI .
>> > 
>> > Maybe the language is not pretty big ?
>> > Thanks,
>> > Or
>> > 
>> > 
>> > On Wednesday, January 23, 2019 at 8:25:32 PM UTC+2, David K. Storrs wrote:
>> > What happens when you run it?  Are you getting any error messages? 
>> > 
>> > On Wed, Jan 23, 2019 at 1:01 PM orenpa11  wrote: 
>> > > 
>> > > Hi 
>> > > I am trying to implemet this code of "snake game " 
>> > > https://course.ccs.neu.edu/csu211/code/snake-full.ss 
>> > > 
>> > > in DrRacket (Pretty big) 
>> > >  But when I run it it is not working . 
>> > > any Idea ? 
>> > > 
>> > > Thanks 
>> > > Or 
>> > > 
>> > > -- 
>> > > 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...@googlegroups.com. 
>> > > For more options, visit https://groups.google.com/d/optout. 
>> > 
>> > -- 
>> > You received this message because you are subscribed to 

Re: [racket-users] Collections and data structures wishlist?

2019-01-18 Thread Matthias Felleisen

> On Jan 18, 2019, at 10:22 PM, jackhfi...@gmail.com wrote:
> 
> 
> - A separation between using lists as homogeneous collections and using lists 
> as fixed-size tuples. So there'd be a separate `tuple?` data type that's 
> structurally equivalent to a list but meant to be used differently. For 
> example, `(list/c number?)` would mean a list of many numbers, but `(tuple/c 
> number?)` would mean a tuple of size 1 containing a number.
> 


"It is better to have 100 functions operate on one data structure than 10 
functions on 10 data structures.” 
http://www.cs.yale.edu/homes/perlis-alan/quotes.html 

"It is better to have 100 transducers operate on one data structure interface 
than 10 functions on 10 data structures.” Rich Hickey, History of Clojure 



-- 
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] Continue (into the future?)

2019-01-18 Thread Matthias Felleisen

It would be wonderful if someone started such a tutorial for RacketScript so 
that we had a driving usecase for the language development — Matthias



> On Jan 18, 2019, at 10:58 AM, Stephen De Gabrielle  
> wrote:
> 
> Hi, 
> 
> While looking at an issue with the rendering of the Continue tutorial, I got 
> to thinking that Continue, as a flagship tutorial for Racket, needs new 
> sections to cover changes in web development practice, especially supporting 
> client side web frameworks(angular,Ember,Vue,React) by building backends that 
> support XMLHttpRequest/WebSockets/Fetch. Other possibilities include
> - developing with client side racket (RacketScript, Urlang, Whalesong?)
> - authentication (both doing it yourself, or using OpenID to) 
> - creating and accessing web API's like AWS, twitter etc.  
> - custom #lang's or eDSL's to support the above (either highlighting existing 
> ones or creating new ones)
> 
> I think the best way to do this would be to develop a tutorial in the _style 
> of_ Continue, then it could be linked from, or integrated into the Continue 
> tutorial.
> 
> Any thoughts? Is this a good or bad idea? Would it be better to focus 
> community effort elsewhere?
> 
> Kind regards, 
> 
> Stephen
> 
> 
> -- 
> 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] Functions that are sometimes tail recursive

2019-01-15 Thread Matthias Felleisen


> On Jan 15, 2019, at 10:13 AM, Will Jukes  wrote:
> 
> Hi everyone,
> 
> I was helping a student the other day with a problem where they were to write 
> a recursive function that uses trial division to return a list of the prime 
> factors of an integer (no fancy optimizations, these are high school kids who 
> don't have a lot of number theory). It looked something like this:
> 
> (define (factor n)
> (let loop ([k n] [d 2])
> (cond [(> d k)  '()]
>   [(zero? (modulo k d))  (cons d (loop (quotient k d) d))]
>   [else  (loop k (add1 d))])))
> 
> 
> 
> The purpose of this lesson was to illustrate the difference between proper 
> tail recursion and regular recursion (our course calls it natural recursion), 
> but it occurred to me that this function is actually tail recursive in the 
> else clause but not in the second clause. This struck me as highly desirable 
> behavior in this case (and possibly others), since even those numbers with 
> relatively many prime factors wouldn't create a very deep stack -- most 
> recursive calls would go to the third clause. I wanted to double check though 
> that Racket (or other Scheme compilers) would recognize the distinction and 
> optimize those calls that can be optimized. My understanding is that they 
> almost certainly would be, but I'm still learning about low-level programming 
> and the implementation is a bit of a black box to me.


It doesn’t optimize such calls, Racket implements them properly, that is, w/o 
consumption of stack space. 

[[ If your student’s curriculum is based on HtDP (your “natural recursion” 
phrase suggests so), he is likely to use Beginning or Intermediate Student 
language and the emphasis is on properly designing the function, not 
performance details. Here the key is that good design calls for an auxiliary 
accumulator-style function. As a teacher, I’d also be happier if the two were 
factored into two explicit function definitions (let-loop defines a function 
implicitly) 

;; N -> [Listof N] 
;; determine the factors of n 
(define (factor n0) 
  (local (;; N N -> [Listof N]
;; accu statement: n0 … n is factor-free of 2 … d (which is quite 
sophisticated for a high school student; good high school) 
(define (factor/acc n d)
   (cond 
  [(> d n) ‘()]
  [else (if (= (modulo n d) 0) (cons d (factor/acc (quotient n 
d) d)) (factor/acc n (add1 d)))])))
(factor/acc n0 2))

HtDP shows an alternative, simpler solutions for less talented college 
students. ]] 

— Matthias



-- 
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: Racket Weet 2019

2019-01-10 Thread Matthias Felleisen


> On Jan 10, 2019, at 2:19 PM, 'Jeff Ward' via Racket Users 
>  wrote:
> 
> Is there a description available for the "How to Design Languages" course?  


Not yet, but it will be quite similar to the 2018 Racket School. Probably in 
late Feb. — Matthias





> 
> I assume that the "Beautiful Racket Workshop" is based on the book by Matthew 
> Butterick.  Is there a reference for the material covered in "How to Design 
> Languages"?  Is it related to the PLT Redex book?
> 
> On Wednesday, November 14, 2018 at 9:45:30 AM UTC-5, Jay McCarthy wrote:
> Racket Week 
> 8-14 July 2019 
> https://con.racket-lang.org/2019/ 
> 
> We're have a week of Racket in summer 2019: 
> - How to Design Languages (5 day intensive from 8th to 12th) 
> - Beautiful Racket Workshop (3 day gentle from 10th to 12th) 
> - RacketCon on 13th 
> - RacketCon Office Hours on 14th 
> 
> Save the date! 
> 
> Jay 
> 
> -- 
> -=[ Jay McCarthy   http://jeapostrophe.github.io]=- 
> -=[ Associate ProfessorPLT @ CS @ UMass Lowell ]=- 
> -=[ Moses 1:33: And worlds without number have I created; ]=- 
> 
> -- 
> 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] Weird behavior when a ‘set’ is the result of ‘eval’

2019-01-10 Thread Matthias Felleisen


Structs are generative. So in different namespaces they mean different things. 


> On Jan 10, 2019, at 1:26 PM, 'Leandro Facchinetti' via Racket Users 
>  wrote:
> 
> Interesting. But what makes sets special? My original program works with 
> hashes, for example:
> 
> #lang racket
> (define h (eval '(begin (require racket/hash) (hash 1 2)) 
> (make-base-namespace)))
> h ;; ⇒ '#hash((1 . 2))
> (hash? h) ;; ⇒ #t (like I expected)
> 
> 
> -- 
> Leandro Facchinetti 
> https://www.leafac.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] Weird behavior when a ‘set’ is the result of ‘eval’

2019-01-10 Thread Matthias Felleisen


> On Jan 10, 2019, at 11:50 AM, 'Leandro Facchinetti' via Racket Users 
>  wrote:
> 
> Please help me understand the following:
> 
> #lang racket
> (define s (eval '(begin (require racket/set) (set 1 2)) 
> (make-base-namespace)))
> s ;; ⇒ (set 1 2)
> (set? s) ;; ⇒ #f (but I expected ‘#t’)
 

Will this help you along: 

#lang racket

(require racket/set)

(define-namespace-anchor a)
(define s (eval '(begin (set 1 2)) (namespace-anchor->namespace a)))
s ;; ⇒ (set 1 2)

(set? s)

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


  1   2   3   4   5   6   7   >