Chrakhan Barzanji | 23 Oct 12:27 2014
Picon

try Racket

hi,
as I mensioned befor I want to create a simpel online cours for programming! TryRacket is  just what i looked for but I want it to be much easyer and the explaination must be in an other language not in english! how can I embed the javaScript  console of TryRacket in my page so that it will be also able to evaluate and get results!
I already see the console in my page but i can't get any result wenn i enter a symbol or any element!
and do i need any permitions to use the console? Creating the online course is a research project of me!
thats how I add the JavaScript in the body of my html(just like tryracket.org):

 <script src="/js/jquery-1.4.2.min.js" type="text/javascript"></script>
 <script src="/js/jquery.console.js" type="text/javascript"></script>
 <script src="/js/tryrkt.js" type="text/javascript"></script>
 <script type="text/javascript">
 evalUrl = "/;((%22k%22%20.%20%22(1853%201%2093643149)%22))";
 </script>

what should I consider, please!

____________________
  Racket Users list:
  http://lists.racket-lang.org/users
Jack Firth | 21 Oct 21:04 2014
Picon

Syntax classes as first-class values

With syntax/parse, would it be possible to make syntax classes first class values instead of just a macro extension on top of syntax parse? That way you could parameterize syntax classes over arbitrary values, including other syntax classes, to create composable syntax classes. For instance, I find it very common when writing complex macros that I need to represent a series of optional keyword clauses like so:

(define-syntax foo
  (syntax-parser
    [(_ req1 req2
         (~optional (~or (~seq #:kw1 op1)
                                 (~seq #:kw2 op2)
                                 (~seq #:kw3 op3)))
         ...)
     ; do something ]))

But this allows for items to be repeated and can be very verbose if the clauses are complex. I can define a syntax class for each of the optional clauses:

(define-splicing-syntax-class op1
  (pattern (~seq #:kw1 op1-pattern)))

(define-splicing-syntax-class op2
  ...
...

I'd like to also be able to define a function that takes those syntax classes and returns a new syntax class representing an optional series of any of those classes where each can be given once:

(define (optional-sequence-of class-a class-b class-c)
  (splicing-syntax-class
    (pattern (~optional (~or (~once (~var a class-a))
                                          (~once  (~var b class-b))
                                          (~once (~var c class-c)))) ...)))

And then my original macro would just be:

(define-syntax foo
  (syntax-parser
    [(_ req1 req2 (~var optionals optional-sequence-of op1 op2 op3))
    ; do something ]))

The reason I think this would be useful is that you could re-use the optional-sequence-of class in other macros since it's generalized. You can make some general "template" syntax classes for common macro tasks, such as a sequence of pairs of unbound unique identifiers with expressions (for let-like macros) or for a definition of a function's arguments (so Racket's definition of a function ((f a b) g) and Typed Racket's definition of a function ((f [a : Number] [b : Number]) [g : Number Number -> Number) could re-use a lot of the same macro plumbing).

I don't know how possible this is, or what issues would need to be ironed out to make it particularly useful, but I welcome any thoughts on the matter.
____________________
  Racket Users list:
  http://lists.racket-lang.org/users
Brian Mastenbrook | 21 Oct 20:19 2014
Picon

Submodules vs hygiene

I am more than a little confused by the behavior of macros that expand to submodules. In the following
example, I don't have any introduced names, but the `x' binding created by the submodule is not usable from
the enclosing module. What confuses me even further is that if I (require (rename-in 'mod [name name]))
instead, it works; I would expect that to always be a no-op. Can anyone explain this behavior?

#lang racket

(define-syntax foo
  (syntax-rules ()
    ((_ mod name)
     (begin
       (module mod racket/base
         (define name 1)
         (provide name))
       (require 'mod)
       name))))

(foo m x)

==> x: unbound identifier in module in: x

--
Brian Mastenbrook
brian@...
http:/brian.mastenbrook.net/


____________________
  Racket Users list:
  http://lists.racket-lang.org/users

James Vanderhyde | 21 Oct 18:15 2014

Media computation

Hello, community. I am going to teach a course on Media Computation this coming spring. I want to use DrRacket. I like Stephen Bloch’s Picturing Programs, and I like how students can manipulate images directly on the REPL. I want a similar interface for manipulating audio. I think the sound should appear in the REPL as a little player control with play/pause, rewind, etc. Does anything like this exist? Does anyone have any ideas for simple audio processing from the REPL? Has anyone taught Media Computation (including audio) using Racket?

James
--
Dr. James Vanderhyde
Math and Computer Science
Benedictine College



____________________
  Racket Users list:
  http://lists.racket-lang.org/users
Chrakhan Barzanji | 21 Oct 13:58 2014
Picon

Scheme within HTML (Web-Server)

Hi,
after i tried to create a html page with Racket embedded and got the answer from you that I schould use WebServer library, now i can't get how it realy works and need help!

I want to create a simple website as a online course for Scheme Language for beginners! my goal is to explane the general functions and operations and so on in scheme but i want  to let the reader be able to try some code and by clicking a button see the result!
ex. he makes input: (+ 1 4) and get result 5 withen my page!
How can i write a html code and let Scheme code be exicuted from the html?
could you explane me with my simple (+ 1 4), please?
I'm using DrRacket!

thank you..
____________________
  Racket Users list:
  http://lists.racket-lang.org/users
enrique comer | 20 Oct 18:06 2014

Auto Response

Gracias por su correo.  Este es solo un acuse de recibo. Que disfruten sus estudios e investigaciones. At³. ECB

____________________
  Racket Users list:
  http://lists.racket-lang.org/users
Jack Firth | 20 Oct 08:16 2014
Picon

Possible issue in the typed version of foldl

I think there may be a mistake in the type definition of foldl for the case that accepts an initial value and three lists and a function of four values to fold them over. The following untyped code runs correctly:

#lang racket (define (f a b c d) d) (define ns '(0 1 2)) (define vs '(a 2 "b")) (foldl f 'ok ns ns vs)

However, the typed form of this code gives a type error:

#lang typed/racket (define: (f [a : Natural] [b : Natural] [c : Any] [d : Symbol]) : Symbol d) (: ns (Listof Natural)) (define ns '(0 1 2)) (: vs (Listof Any)) (define vs '(a 2 "b")) (foldl f 'ok ns ns vs)

Specifically, the type checker outputs:

Type Checker: Polymorphic function `foldl' could not be applied to arguments: Types: (-> a b c d d) d (Listof a) (Listof b) (Listof d) -> d (-> a b c c) c (Listof a) (Listof b) -> c (-> a b b) b (Listof a) -> b Arguments: (-> Nonnegative-Integer Nonnegative-Integer Any Symbol Symbol) 'ok (Listof Nonnegative-Integer) (Listof Nonnegative-Integer) (Listof Any) Expected result: AnyValues in: (foldl f (quote ok) ns ns vs)

I think the issue may be in that first line of the type definition, (-> a b c d d) d (Listof a) (Listof b) (Listof d) -> d. Shouldn’t that last argument type be (Listof c) instead of (Listof d)?

____________________
  Racket Users list:
  http://lists.racket-lang.org/users
Doug Hockin | 18 Oct 18:46 2014
Picon

Dr Racket 6.1 crashes on OS-X 10.10 Darwin

I just installed Racket 6.1 on Mac OS X 10.10 Darwin. When I started up 
Dr Racket it puts up its start-up frame and when it's finished filling 
everything in it crashes. Here's the system overview and the early part 
of the crash output. I send off a report to Apple but it's probably not 
their problem. It's repeatable, I've had it happen three different times.

-- Doug

System Software Overview:

   System Version:    OS X 10.10 (14A389)
   Kernel Version:    Darwin 14.0.0
   Boot Volume:    Macintosh HD
   Boot Mode:    Normal
   Computer Name:    Doug’s MacBook Pro
   Secure Virtual Memory:    Enabled
   Time since boot:    10:13

=============================

Process:               DrRacket [588]
Path:                  /Applications/Racket 
v6.1/DrRacket.app/Contents/MacOS/DrRacket
Identifier:            org.racket-lang.DrRacket
Version:               6.1 (6.1)
Code Type:             X86-64 (Native)
Parent Process:        ??? [1]
Responsible:           DrRacket [588]
User ID:               501

Date/Time:             2014-10-17 23:13:38.123 -0700
OS Version:            Mac OS X 10.10 (14A389)
Report Version:        11
Anonymous UUID:        FD7DDE93-14E7-DC36-61B7-3CDBA28FBDB9

Time Awake Since Boot: 2400 seconds

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000000

VM Regions Near 0:
-->
     __TEXT                 0000000100000000-0000000100008000 [ 32K] 
r-x/rwx SM=COW  /Applications/Racket 
v6.1/DrRacket.app/Contents/MacOS/DrRacket

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libpangocairo-1.0.0.dylib         0x0000000106213942 
basic_engine_shape + 530
1   libpango-1.0.0.dylib              0x000000010615a95f 
_pango_engine_shape_shape + 47
2   libpango-1.0.0.dylib              0x000000010616e6c2 
pango_shape_full + 194
3   libpango-1.0.0.dylib              0x000000010616652a shape_run + 714
4   libpango-1.0.0.dylib              0x0000000106165b8a process_item + 250
5   libpango-1.0.0.dylib              0x000000010615f19f 
pango_layout_check_lines + 2351
6   libpango-1.0.0.dylib              0x0000000106161283 
pango_layout_get_unknown_glyphs_count + 195
7   Racket                            0x000000010034907c ffi_call_unix64 
+ 76
8   Racket                            0x00000001003498ec ffi_call + 860
9   Racket                            0x000000010033a35f ffi_do_call + 2143
10  Racket                            0x0000000100339adc 
ffi_do_call_after_stack_check + 268
11  ???                               0x00000001005f9b4e 0 + 4301232974
12  ???                               0x000000011049eb8d 0 + 4568247181
13  ???                               0x00000001014f60ed 0 + 4316946669
14  Racket                            0x000000010009ba5b _apply_native + 267
15  Racket                            0x000000010009c562 
scheme_apply_chaperone + 2674
16  Racket                            0x0000000100069cd1 scheme_do_eval 
+ 3537
17  Racket                            0x000000010006c656 
_scheme_apply_multi_from_native + 342
18  ???                               0x00000001014f553c 0 + 4316943676
19  Racket                            0x000000010006bb25 scheme_do_eval 
+ 11301
20  Racket                            0x00000001000a383f 
scheme_dynamic_wind + 1119
21  Racket                            0x0000000100094349 dynamic_wind + 329
22  ???                               0x00000001005f1114 0 + 4301197588
23  ???                               0x00000001014f55f9 0 + 4316943865
24  ???                               0x00000001014f55f9 0 + 4316943865
25  Racket                            0x000000010006bb25 scheme_do_eval 
+ 11301
26  Racket                            0x00000001000a383f 
scheme_dynamic_wind + 1119
27  Racket                            0x0000000100094349 dynamic_wind + 329
28  ???                               0x00000001005f1114 0 + 4301197588
29  Racket                            0x000000010006bb25 scheme_do_eval 
+ 11301
30  Racket                            0x000000010009fa90 
scheme_finish_apply_for_prompt + 624
31  Racket                            0x000000010009fe00 
scheme_apply_for_prompt + 112
32  Racket                            0x0000000100090baf 
call_with_prompt + 1743
33  ???                               0x00000001005f1114 0 + 4301197588
34  Racket                            0x000000010006bb25 scheme_do_eval 
+ 11301
35  Racket                            0x000000010006c656 
_scheme_apply_multi_from_native + 342
36  ???                               0x00000001014cac5c 0 + 4316769372
37  ???                               0x00000001014ca85d 0 + 4316768349
38  ???                               0x00000001014ca85d 0 + 4316768349
39  ???                               0x00000001014ca85d 0 + 4316768349
40  ???                               0x00000001014ca85d 0 + 4316768349
41  ???                               0x00000001014ca85d 0 + 4316768349
42  ???                               0x00000001014ca85d 0 + 4316768349
43  ???                               0x00000001014ca85d 0 + 4316768349
44  ???                               0x00000001014ca85d 0 + 4316768349
45  ???                               0x00000001014ca85d 0 + 4316768349
46  ???                               0x00000001014ca85d 0 + 4316768349
47  ???                               0x00000001014ca85d 0 + 4316768349
48  ???                               0x00000001014ca85d 0 + 4316768349
49  ???                               0x00000001014ca85d 0 + 4316768349
50  ???                               0x00000001014ca85d 0 + 4316768349
51  ???                               0x00000001014ca85d 0 + 4316768349
52  ???                               0x00000001014ca85d 0 + 4316768349
53  ???                               0x00000001014ca85d 0 + 4316768349
54  ???                               0x00000001014ca85d 0 + 4316768349
55  ???                               0x00000001014ca85d 0 + 4316768349
56  ???                               0x00000001014ca85d 0 + 4316768349
57  ???                               0x00000001014ca85d 0 + 4316768349
58  ???                               0x00000001014ca85d 0 + 4316768349
59  ???                               0x00000001014ca85d 0 + 4316768349
60  Racket                            0x000000010006bb25 scheme_do_eval 
+ 11301
61  Racket                            0x00000001000a383f 
scheme_dynamic_wind + 1119
62  Racket                            0x0000000100094349 dynamic_wind + 329
63  ???                               0x00000001005f1114 0 + 4301197588
64  ???                               0x00000001014f55f9 0 + 4316943865
65  ???                               0x00000001014f55f9 0 + 4316943865
66  Racket                            0x000000010006bb25 scheme_do_eval 
+ 11301
67  Racket                            0x00000001000a383f 
scheme_dynamic_wind + 1119
68  Racket                            0x0000000100094349 dynamic_wind + 329
69  ???                               0x00000001005f1114 0 + 4301197588
70  Racket                            0x000000010006bb25 scheme_do_eval 
+ 11301
71  Racket                            0x000000010009fa90 
scheme_finish_apply_for_prompt + 624
72  Racket                            0x000000010009fe00 
scheme_apply_for_prompt + 112
73  Racket                            0x0000000100090baf 
call_with_prompt + 1743
74  ???                               0x00000001005f1114 0 + 4301197588
75  ???                               0x0000000102ff3dfd 0 + 4345249277
76  ???                               0x00000001005fba49 0 + 4301240905
77  ???                               0x00000001014ca85d 0 + 4316768349
78  Racket                            0x000000010006bb25 scheme_do_eval 
+ 11301
79  Racket                            0x000000010009fa90 
scheme_finish_apply_for_prompt + 624
80  Racket                            0x000000010009fe00 
scheme_apply_for_prompt + 112
81  Racket                            0x0000000100090baf 
call_with_prompt + 1743
82  ???                               0x00000001005f1114 0 + 4301197588
83  Racket                            0x000000010006bb25 scheme_do_eval 
+ 11301
84  Racket                            0x000000010009fa90 
scheme_finish_apply_for_prompt + 624
85  Racket                            0x000000010009fe00 
scheme_apply_for_prompt + 112
86  Racket                            0x0000000100090baf 
call_with_prompt + 1743
87  ???                               0x00000001005f1114 0 + 4301197588
88  ???                               0x00000001014cacfb 0 + 4316769531
89  Racket                            0x000000010006bb25 scheme_do_eval 
+ 11301
90  Racket                            0x00000001000978c2 force_values + 402
91  Racket                            0x00000001000979a4 
scheme_force_value_same_mark + 132
92  ???                               0x00000001005fb25d 0 + 4301238877
93  Racket                            0x000000010006bb25 scheme_do_eval 
+ 11301
94  Racket                            0x000000010006c656 
_scheme_apply_multi_from_native + 342
95  ???                               0x00000001005f1056 0 + 4301197398
96  Racket                            0x000000010006bb25 scheme_do_eval 
+ 11301
97  Racket                            0x0000000100097cf8 apply_k + 264
98  Racket                            0x0000000100097438 
scheme_top_level_do_worker + 1976
99  org.racket-lang.DrRacket          0x0000000100004c4c 0x100000000 + 19532
100 org.racket-lang.DrRacket          0x00000001000034cc 0x100000000 + 13516
101 Racket                            0x0000000100010eba 
scheme_main_stack_setup + 330
102 org.racket-lang.DrRacket          0x0000000100001734 0x100000000 + 5940
103 org.racket-lang.DrRacket          0x0000000100001674 0x100000000 + 5748

Thread 1:
0   libsystem_kernel.dylib            0x00007fff976d552e mach_msg_trap + 10
1   libsystem_kernel.dylib            0x00007fff976d469f mach_msg + 55
2   Racket                            0x000000010034a7e6 
exception_thread + 134
3   libsystem_pthread.dylib           0x00007fff8d07a2fc _pthread_body + 131
4   libsystem_pthread.dylib           0x00007fff8d07a279 _pthread_start 
+ 176
5   libsystem_pthread.dylib           0x00007fff8d0784b1 thread_start + 13

Thread 2:
0   libsystem_kernel.dylib            0x00007fff976da486 
__semwait_signal + 10
1   libsystem_c.dylib                 0x00007fff9410de70 usleep + 54
2   Racket                            0x000000010024393b 
green_thread_timer + 43
3   Racket                            0x00000001001c0de1 
mzrt_thread_stub + 81
4   libsystem_pthread.dylib           0x00007fff8d07a2fc _pthread_body + 131
5   libsystem_pthread.dylib           0x00007fff8d07a279 _pthread_start 
+ 176
6   libsystem_pthread.dylib           0x00007fff8d0784b1 thread_start + 13

Thread 3:: Dispatch queue: com.apple.libdispatch-manager
0   libsystem_kernel.dylib            0x00007fff976db22e kevent64 + 10
1   libdispatch.dylib                 0x00007fff8e608a6a 
_dispatch_mgr_thread + 52

Thread 4:
0   libsystem_kernel.dylib            0x00007fff976da946 
__workq_kernreturn + 10
1   libsystem_pthread.dylib           0x00007fff8d0784a1 start_wqthread + 13

Thread 5:
0   libsystem_kernel.dylib            0x00007fff976da946 
__workq_kernreturn + 10
1   libsystem_pthread.dylib           0x00007fff8d0784a1 start_wqthread + 13

Thread 6:
0   libsystem_kernel.dylib            0x00007fff976da946 
__workq_kernreturn + 10
1   libsystem_pthread.dylib           0x00007fff8d0784a1 start_wqthread + 13

Thread 7:: com.apple.CFSocket.private
0   libsystem_kernel.dylib            0x00007fff976da3f6 __select + 10
1   libsystem_pthread.dylib           0x00007fff8d07a2fc _pthread_body + 131
2   libsystem_pthread.dylib           0x00007fff8d07a279 _pthread_start 
+ 176
3   libsystem_pthread.dylib           0x00007fff8d0784b1 thread_start + 13

Thread 8:
0   libsystem_kernel.dylib            0x00007fff976d552e mach_msg_trap + 10
1   libsystem_kernel.dylib            0x00007fff976d469f mach_msg + 55
2   com.apple.CoreFoundation          0x00007fff95183b14 
__CFRunLoopServiceMachPort + 212
3   com.apple.CoreFoundation          0x00007fff95182fdb __CFRunLoopRun 
+ 1371
4   com.apple.CoreFoundation          0x00007fff95182838 
CFRunLoopRunSpecific + 296
5   com.apple.AppKit                  0x00007fff8b4ce8f7 _NSEventThread 
+ 137
6   libsystem_pthread.dylib           0x00007fff8d07a2fc _pthread_body + 131
7   libsystem_pthread.dylib           0x00007fff8d07a279 _pthread_start 
+ 176
8   libsystem_pthread.dylib           0x00007fff8d0784b1 thread_start + 13

Thread 9:
0   libsystem_kernel.dylib            0x00007fff976da946 
__workq_kernreturn + 10
1   libsystem_pthread.dylib           0x00007fff8d0784a1 start_wqthread + 13

Thread 0 crashed with X86 Thread State (64-bit):
   rax: 0x0000000000000000  rbx: 0x0000000000000000  rcx: 
0x0000000000000000  rdx: 0x0000000105d74c40
   rdi: 0x0000000000000102  rsi: 0xffffffffffffffff  rbp: 
0x00007fff5fbfa7c0  rsp: 0x00007fff5fbfa690
    r8: 0x000000000000000b   r9: 0x00006000000b4520  r10: 
0x0000000108707158  r11: 0x0000000108707158
   r12: 0x0000000105d74c10  r13: 0x00006000000b4520  r14: 
0x0000000000000001  r15: 0x0000000000000000
   rip: 0x0000000106213942  rfl: 0x0000000000010246  cr2: 0x0000000000000000

Logical CPU:     0
Error Code:      0x00000004
Trap Number:     14

____________________
  Racket Users list:
  http://lists.racket-lang.org/users
Asumu Takikawa | 17 Oct 21:22 2014

Using parameters in register-finalizer

Hi all,

It appears that finalizers for register-finalizer are run in a special
thread that has an empty thread cell table, but it seems like this makes
certain parameters like `current-output-port` return #f instead of the
documented value.

Is that the expected behavior?

Welcome to Racket v6.1.1.1.
-> (require ffi/unsafe)
   (let () (define x (box 3)) (register-finalizer x (lambda (x) (displayln "hi"))))
-> (collect-garbage)
-> displayln: contract violation
  expected: output-port?
  given: #f
  argument position: 2nd
  other arguments...:
   "hi"

Cheers,
Asumu
____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Christian Wagenknecht | 17 Oct 18:29 2014
Picon

constant vs. variable behavior

In the example as given below 'a' behaves like a constant whereas the value named with 'x' can be modified (in
the interaction window) as expected. Could you help me please to understand what happened by (set! x "Bob")?

Definition window

#lang racket

(define a "Hello")

(define x "Hello")
(set! x "Bob")

Interaction window

 > (set! a 3)
. . set!: assignment disallowed;
  cannot modify a constant
   constant: a
 > (set! x 9)
 > x
9

Attachment (smime.p7s): application/pkcs7-signature, 6505 bytes
____________________
  Racket Users list:
  http://lists.racket-lang.org/users
Roelof Wobben | 16 Oct 19:06 2014
Picon

book for a absolute beginner

Hello,

Does anyone know a good book for a absolute beginner in racket with a 
lot of exercises so I can check if I understand anything right ?

Roelof

____________________
  Racket Users list:
  http://lists.racket-lang.org/users


Gmane