Re: [racket-users] Question : Local Definition

2015-07-24 Thread sagyo12341234
Thanks for very good answer.

-- 
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] Scribble undefined tags

2015-07-24 Thread Matthew Butterick
I’ve always found that it’s more reliable to use fully-qualified package
names with `for-label`, e.g.

(require (for-label jordan/package))

rather than

(require (for-label "main.rkt"))

Once upon a time I had similar problems, and noticed that fully-qualified
names is the habit used in many internal Racket packages. The reasons why
this works are dimly remembered. I presume it has something to do with the
fact that all Scribble docs are rendered into the main docs directory for
your installation, thus breaking local paths that wander outside your
'scribblings' subdirectory.

On Fri, Jul 24, 2015 at 8:58 AM, Jordan Johnson  wrote:

> Hi all,
>
> I have a file *main.scrbl* in the same directory as a file *main.rkt*. In
> the .scrbl file, I have
>
> (require (for-label "main.rkt"))
>
> and several *defproc* and *defstruct** forms. For some reason, one of my
> *defstruct** forms works as expected, while all of the other *defstruct** and
> *defproc* forms produce undefined-tag warnings (when I build the docs via
> raco setup), and compile to a red-underlined name in the resulting HTML.
>
> In DrRacket, mousing over the struct names in *main.scrbl*, I see a pink
> arrow with a question mark pointing from the *for-label* line to the
> struct name, and DrRacket correctly reports that the struct name’s binding
> is imported from *main.rkt*.
>
> What might I be missing, that could be causing undefined-tag errors?
>
> Thanks,
> jmj
>
>  --
> 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] Question : Local Definition

2015-07-24 Thread Alexander D. Knauth

On Jul 25, 2015, at 12:20 AM, Alexander D. Knauth  wrote:

> 
> On Jul 24, 2015, at 11:29 PM, sagyo12341...@gmail.com wrote:
> 
>> Nice to meet you.
>> 
>> 
>> I'm a racket beginner and I'm not a English speaker. Please forgive my poor 
>> skills.
>> 
>> In racket tutorials or HtDP, it uses some local definitions, as follows:
>> 
>> (define (f x)
>> (local [((define g x) (add1 x))]
>>   (f (g x.
>> 
>> I'm not sure about the difference from the code:
>> 
>> (define (f x)
>> (define (g x) (add1 x))
>> (f (g x))).
>> 
>> Please help me. Thank you.
>> 
>> Taro
> 
> Other than the misplaced paren typo in the first bit of code, these will do 
> exactly the same thing.

It's a matter of style. (Unless of course you're in an HTDP language that 
doesn't support internal definitions.)

There are times when I prefer local, for instance, when I want to clearly 
separate the definitions from the last expression, or when I want to indent the 
definitions more than the last expression.  

But there are also many times when an internal definition context is just more 
convenient, since comes with less keystrokes, less parens, and less 
indentation, and a bit more flexibility, especially if I want to put some 
debugging or error checking code in there.


-- 
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] Question : Local Definition

2015-07-24 Thread Alexander D. Knauth

On Jul 24, 2015, at 11:29 PM, sagyo12341...@gmail.com wrote:

> Nice to meet you.
> 
> 
> I'm a racket beginner and I'm not a English speaker. Please forgive my poor 
> skills.
> 
> In racket tutorials or HtDP, it uses some local definitions, as follows:
> 
> (define (f x)
>  (local [((define g x) (add1 x))]
>(f (g x.
> 
> I'm not sure about the difference from the code:
> 
> (define (f x)
>  (define (g x) (add1 x))
>  (f (g x))).
> 
> Please help me. Thank you.
> 
> Taro

Other than the misplaced paren typo in the first bit of code, these will do 
exactly the same thing.

Alex Knauth


-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Question : Local Definition

2015-07-24 Thread sagyo12341234
Nice to meet you.


I'm a racket beginner and I'm not a English speaker. Please forgive my poor 
skills.

In racket tutorials or HtDP, it uses some local definitions, as follows:

(define (f x)
  (local [((define g x) (add1 x))]
(f (g x.

I'm not sure about the difference from the code:

(define (f x)
  (define (g x) (add1 x))
  (f (g x))).

Please help me. Thank you.

Taro

-- 
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] What limits would you put on racket?

2015-07-24 Thread John Carmack
Half-life was written in C on my Quake 1 codebase.

-Original Message-
From: racket-users@googlegroups.com [mailto:racket-users@googlegroups.com] On 
Behalf Of Hendrik Boom
Sent: Thursday, July 23, 2015 7:15 PM
To: Racket Users
Subject: Re: [racket-users] What limits would you put on racket?

On Thu, Jul 23, 2015 at 07:48:38PM -0400, Neil Van Dyke wrote:
> 
> * 3D action games.  I haven't yet tried this one yet with Racket, and 
> it *might* be doable even with the current stock VM, but I anticipate 
> GC pauses being an issue to get past.  I'm not going to write a 3D 
> game engine in CL, neither, and, realistically, I'd probably end up 
> doing the performance/realtime-sensitive parts in C or C++ (or 
> something that compiles to C/C++, or to LLVM), plus whatever is 
> appropriate to offload to the GPU.

I've heard that half-life waswritten in a versino of Lisp.
But the battles in half-life tend to be short, so they explicitly called the 
garbage collector between battles. 

-- hendrik

--
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://urldefense.proofpoint.com/v1/url?u=https://groups.google.com/d/optout&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=Kjg6LltY9QjkipKooaVldA%3D%3D%0A&m=77tyOJbc%2BjZ2ASCooTvHV0Qeswwty9IwC%2B8aP9XX%2B6U%3D%0A&s=2c6a633611ab51194051c3be6053626c69f05d4a7dd534c78dd5f3a565f5806a.

-- 
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] What limits would you put on racket?

2015-07-24 Thread Robby Findler
Just in case, you might want to check out Racket's places and futures
constructs.

On Friday, July 24, 2015, Dmitry Igrishin  wrote:

>
>
> 2015-07-24 2:48 GMT+03:00 Neil Van Dyke  >:
>
>> On Racket, CL, limits, programmers...
>>
>> I've found that most stuff can be done in Racket, and, though I have used
>> CL when required by two consulting clients' prior implementation choices,
>> I'm not aware that CL has any key advantages over Racket.  (Not bashing CL;
>> it's a nice platform, with an unusually smart developer community.  And,
>> earlier in Racket's development, CL was noticeably more proven and mature
>> for industrial use.  I just have few complaints about being married Racket
>> today, and there's no temptation to philander with CL.)
>>
> As for me, the most noticeable difference between Common Lisp and Racket
> that the
> most popular implementations of former provides facilities for multiple
> /hardware/ threads
> of execution. And this is one of the primary reasons why I use Common Lisp
> as well.
>
>
> --
> // Dmitry.
>
>  --
> 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] easy question about `free-identifier=?`

2015-07-24 Thread Matthew Flatt
The documentation's intent is to describe about syntax objects that
represent an expanded expression. When you write

 (define stx #'(let ([x 5]) (+ x 6)))

then the syntax object `stx` doesn't represent an expansion. Instead,
it's a pile symbols and pairs, all with the same lexical context (taken
from the surrounding module).

Expanding that syntax object produces a new one with the richer
information that the documentation is intended to describe. Concretely,
the tests pass if you change `stxs` to:

  (define stxs (syntax-flatten (expand stx)))


At Fri, 24 Jul 2015 11:18:55 -0700, Matthew Butterick wrote:
> According to the docs [1]:
> 
> > (let ([x 5]) (+ x 6))
> > 
> > Combining the lexical information from 'let' in the program above to 'x 
> would not produce an identifier that is `free-identifier=?` to either 'x', 
> since it does not appear in the scope of the 'x' binding.
> 
> If so, then what is the flaw in the program below, which is intended to test 
> this proposition? `free-identifier=?` comes out false only when the new 
> identifier has a different name.
> 
> ;
> 
> #lang racket
> (require rackunit)
> 
> (define stx #'(let ([x 5]) (+ x 6)))
> 
> (define (syntax-flatten stx)
>   (flatten
>(let loop ([stx stx])
>  (define stxs (syntax->list stx))
>  (if stxs
>  (map loop stxs)
>  stx
> 
> (define stxs (syntax-flatten stx))
> (define stx-let (first stxs))
> (define stx-x1 (second stxs))
> (define stx-x2 (fifth stxs))
> 
> ;; these will fail
> (check-false (free-identifier=? (datum->syntax stx-let 'x) stx-x1))
> (check-false (free-identifier=? (datum->syntax stx-let 'x) stx-x2))
> 
> ;; but these will succeed
> (check-false (free-identifier=? (datum->syntax stx-let 'xxx) stx-x1))
> (check-false (free-identifier=? (datum->syntax stx-let 'xxx) stx-x2))
> 
> ;
> 
> 
> 
> 
> [1] 
> http://docs.racket-lang.org/reference/syntax-model.html#%28part._id-model%29
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] easy question about `free-identifier=?`

2015-07-24 Thread Matthew Butterick
According to the docs [1]:

> (let ([x 5]) (+ x 6))
> 
> Combining the lexical information from 'let' in the program above to 'x would 
> not produce an identifier that is `free-identifier=?` to either 'x', since it 
> does not appear in the scope of the 'x' binding.

If so, then what is the flaw in the program below, which is intended to test 
this proposition? `free-identifier=?` comes out false only when the new 
identifier has a different name.

;

#lang racket
(require rackunit)

(define stx #'(let ([x 5]) (+ x 6)))

(define (syntax-flatten stx)
  (flatten
   (let loop ([stx stx])
 (define stxs (syntax->list stx))
 (if stxs
 (map loop stxs)
 stx

(define stxs (syntax-flatten stx))
(define stx-let (first stxs))
(define stx-x1 (second stxs))
(define stx-x2 (fifth stxs))

;; these will fail
(check-false (free-identifier=? (datum->syntax stx-let 'x) stx-x1))
(check-false (free-identifier=? (datum->syntax stx-let 'x) stx-x2))

;; but these will succeed
(check-false (free-identifier=? (datum->syntax stx-let 'xxx) stx-x1))
(check-false (free-identifier=? (datum->syntax stx-let 'xxx) stx-x2))

;




[1] http://docs.racket-lang.org/reference/syntax-model.html#%28part._id-model%29

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Scribble undefined tags

2015-07-24 Thread Jordan Johnson
Hi all,

I have a file main.scrbl in the same directory as a file main.rkt. In the 
.scrbl file, I have

(require (for-label "main.rkt"))

and several defproc and defstruct* forms. For some reason, one of my defstruct* 
forms works as expected, while all of the other defstruct* and defproc forms 
produce undefined-tag warnings (when I build the docs via raco setup), and 
compile to a red-underlined name in the resulting HTML.

In DrRacket, mousing over the struct names in main.scrbl, I see a pink arrow 
with a question mark pointing from the for-label line to the struct name, and 
DrRacket correctly reports that the struct name’s binding is imported from 
main.rkt.

What might I be missing, that could be causing undefined-tag errors?

Thanks,
jmj

-- 
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] Wanted: Crazy nested lambda test cases

2015-07-24 Thread Hendrik Boom
On Thu, Jul 23, 2015 at 01:09:10PM -0500, Emmanuel Schanzer wrote:
> Hi all - I’ve recently pushed a tweak to WeScheme’s compiler, which should do 
> a better job matching DrRacket’s behavior when compiling 
> lambdas-within-lambdas, and lambdas-that-produce-lambdas.
> 
> I’m looking for sadistic test cases (preferably not using local) to 
> stress-test. Anybody have any good ones lying around? Feel free to take the 
> new compiler for a spin at http://197.wescheme.appspot.com/openEditor 
> , but please send me any good 
> tests that you have as well!

Try Knuth's man or boy problem (alleed to have been called that because it test 
whether a compiler it a "Man" compiler, or merely a "boy" compiler)"

https://en.wikipedia.org/wiki/Man_or_boy_test
http://rosettacode.org/wiki/Man_or_boy_test

-- hendrik
k

-- 
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] What limits would you put on racket?

2015-07-24 Thread Hendrik Boom
On Thu, Jul 23, 2015 at 08:57:29PM -0400, Neil Van Dyke wrote:
> Hendrik Boom wrote on 07/23/2015 08:15 PM:
> >I've heard that half-life waswritten in a versino of Lisp. But the
> >battles in half-life tend to be short, so they explicitly called
> >the garbage collector between battles.
> 
> And now HL3 is merely delayed by a *really* long deferred GC cycle? :)

Exactly! -- for the original half-life.  I don't know about the current 
ones.

> 
> But seriously, I'm idly toying with a game idea that needs
> uninterrupted smooth fast action (physics, graphics, world model,
> networking, controlling) for up to 5 minutes. A multiplayer game
> session is longer than 5 minutes, but is split into parts of up to 5
> minutes, with brief GC-friendly gameplay pauses between the parts,
> and afterwards you return to the GC-friendly multiplayer lobby.  An
> issue with this sort of thing in GC'd languages is that you know
> you're going to have to deal with GC somehow, and you'll have to
> prove viability empirically, after considerable investment; but if
> you were using C/C++, what you have to prove empirically after
> considerable investment is that you can do it without memory bugs.

You might be interested in the language Styx, the language that goes with 
the Inferno operating system.  I believe it uses reference counting up 
front, with full garbage collection as a backstop.

Inferno can be run on the bare metal, but also as a user process on Linux 
(and some other OS's, I believe).

-- hendrik

> 
> Neil V.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] What limits would you put on racket?

2015-07-24 Thread Dmitry Igrishin
2015-07-24 2:48 GMT+03:00 Neil Van Dyke :

> On Racket, CL, limits, programmers...
>
> I've found that most stuff can be done in Racket, and, though I have used
> CL when required by two consulting clients' prior implementation choices,
> I'm not aware that CL has any key advantages over Racket.  (Not bashing CL;
> it's a nice platform, with an unusually smart developer community.  And,
> earlier in Racket's development, CL was noticeably more proven and mature
> for industrial use.  I just have few complaints about being married Racket
> today, and there's no temptation to philander with CL.)
>
As for me, the most noticeable difference between Common Lisp and Racket
that the
most popular implementations of former provides facilities for multiple
/hardware/ threads
of execution. And this is one of the primary reasons why I use Common Lisp
as well.


-- 
// Dmitry.

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