[racket-users] reporting contract violations in executable programs

2018-11-01 Thread Alexander McLin
I’m a little confused here, to me it looks like the second contract violation 
is completely different from the first one.

You were expecting `foo` to raise a contract violation but in your executable 
example it appears that contract violation is being raised by the `build-path` 
function not `foo`.

Maybe it’s a entirely different error?

-- 
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 tighten the contract on a function

2018-09-05 Thread Alexander McLin
Something like the following program:

#lang racket

(module foomod racket
  (provide foo)
  (define/contract (foo arg) (-> string? #t) #t))

(require 'foomod)
(provide (contract-out (foo (-> non-empty-string? #t




On Tuesday, September 4, 2018 at 9:00:06 PM UTC-4, David K. Storrs wrote:
>
>
>
> On Tue, Sep 4, 2018 at 8:55 PM, Matthew Butterick  > wrote:
>
>>
>> On Sep 4, 2018, at 3:54 PM, David Storrs > > wrote:
>>
>> Say I have this (possibly from a third-party module):
>>
>>   (define/contract (foo arg) (-> string? #t) #t)
>>
>> I want to ensure that the argument is always non-empty, so I tighten the 
>> contract.  I could do this:
>>
>>   (set! foo (contract (-> non-empty-string? #t) foo 'foo 'neg))
>>
>> Mutating the function is pretty ugly, but I'm not sure of a better way.  
>>
>>
>>
>> Seems like this technique would break down with imported identifiers, for 
>> instance:
>>
>> ;
>>
>> #lang racket
>>
>> (module foomod racket
>>   (provide foo)
>>   (define/contract (foo arg) (-> string? #t) #t))
>> (require 'foomod)
>>
>> (set! foo (contract (-> non-empty-string? #t) foo 'foo 'neg))
>>
>> (foo "") ; error: set!: cannot mutate module-required identifier in: foo
>>
>>
>>
>>
> Ah, good point.  I'd realized that the tighter version would be visible 
> only in the current module, but I hadn't noticed that you actually can't 
> mutate imports.  Thanks.
>
>
>> I am left with the following questions:
>>
>> 1) Is there a better way to do this?
>>
>>
>> Why not the old prefix-and-wrap?
>>
>> ;
>>
>> #lang racket
>>
>> (module foomod racket
>>   (provide foo)
>>   (define/contract (foo arg) (-> string? #t) #t))
>> (require (prefix-in lax: 'foomod))
>>
>> (define foo (contract (-> non-empty-string? #t) lax:foo 'foo 'neg))
>>
>> (foo "")
>>
>>
> That works.  
>
>
>>
>> 2) If I use this method in a module other than the one where foo was 
>> defined, my expectation is that I would affect it only in the current 
>> module but that other importers would not see the change.  Is this right?
>>
>>
>> When you export this new `foo`, it carries the new contract, of course. 
>> (The old one remains but because your wrapper contract is tighter, any 
>> contract blame will happen in the new contract)
>>
>
> Great, thanks.  This does exactly what I need. 
>
>

-- 
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 tighten the contract on a function

2018-09-05 Thread Alexander McLin
What about reproviding foo and using contract-out to wrap foo in a new 
contract?





On Tuesday, September 4, 2018 at 9:00:06 PM UTC-4, David K. Storrs wrote:
>
>
>
> On Tue, Sep 4, 2018 at 8:55 PM, Matthew Butterick  > wrote:
>
>>
>> On Sep 4, 2018, at 3:54 PM, David Storrs > > wrote:
>>
>> Say I have this (possibly from a third-party module):
>>
>>   (define/contract (foo arg) (-> string? #t) #t)
>>
>> I want to ensure that the argument is always non-empty, so I tighten the 
>> contract.  I could do this:
>>
>>   (set! foo (contract (-> non-empty-string? #t) foo 'foo 'neg))
>>
>> Mutating the function is pretty ugly, but I'm not sure of a better way.  
>>
>>
>>
>> Seems like this technique would break down with imported identifiers, for 
>> instance:
>>
>> ;
>>
>> #lang racket
>>
>> (module foomod racket
>>   (provide foo)
>>   (define/contract (foo arg) (-> string? #t) #t))
>> (require 'foomod)
>>
>> (set! foo (contract (-> non-empty-string? #t) foo 'foo 'neg))
>>
>> (foo "") ; error: set!: cannot mutate module-required identifier in: foo
>>
>>
>>
>>
> Ah, good point.  I'd realized that the tighter version would be visible 
> only in the current module, but I hadn't noticed that you actually can't 
> mutate imports.  Thanks.
>
>
>> I am left with the following questions:
>>
>> 1) Is there a better way to do this?
>>
>>
>> Why not the old prefix-and-wrap?
>>
>> ;
>>
>> #lang racket
>>
>> (module foomod racket
>>   (provide foo)
>>   (define/contract (foo arg) (-> string? #t) #t))
>> (require (prefix-in lax: 'foomod))
>>
>> (define foo (contract (-> non-empty-string? #t) lax:foo 'foo 'neg))
>>
>> (foo "")
>>
>>
> That works.  
>
>
>>
>> 2) If I use this method in a module other than the one where foo was 
>> defined, my expectation is that I would affect it only in the current 
>> module but that other importers would not see the change.  Is this right?
>>
>>
>> When you export this new `foo`, it carries the new contract, of course. 
>> (The old one remains but because your wrapper contract is tighter, any 
>> contract blame will happen in the new contract)
>>
>
> Great, thanks.  This does exactly what I need. 
>
>

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


[racket-users] Re: Recommendation for learning syntax?

2018-08-07 Thread Alexander McLin
I was an attendee of Racket Summer School 2018 where we covered 
syntax-parse extensively.

The lecture plans and problem assignments are still available online and 
they together comprise a good tutorial for syntax-parse and language design 
principles.

I encourage you to give it a try! 
https://summer-school.racket-lang.org/2018/plan/  


-- 
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] Unicode identifiers

2018-05-16 Thread Alexander McLin
Would it be possible to adjust the readtable to replace "→" with "->" ?



On Wednesday, May 16, 2018 at 10:32:43 AM UTC-4, Andrew Kent wrote:
>
> `racket/string` needs to be required _for syntax_ in order to work in the 
> suggested way (because it's bindings are needed at compile time).
>
> The following works for me in a module:
>
> ```
> #lang racket/base
>
> (require (for-syntax racket/base racket/string)
>  racket/require)
>
> (require (filtered-in
>   (λ (name)
> (string-replace name "->" "→"))
>   racket))
>
> (string→number "42")
> ```
>

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


[racket-users] Re: error in DrRacket but not in script

2018-04-10 Thread Alexander McLin
My guess the problem is 

(define imleftname
  #"./tsukubaleft.jpg")

You're using a relative path to the jpg file which may be valid wherever 
your script file is located but DrRacket is probably starting up with a 
different working directory and the relative path is not resolving 
successfully.

I would suggest trying using `define-runtime-path` which deals with that 
kind of issue. It will automatically create the correct fully resolved path 
when you give it a relative path.

For example, do it like this:

(define-runtime-path imleftname "./tsukubaleft.jpg")


On Tuesday, April 10, 2018 at 4:38:12 AM UTC-4, Frédéric Morain-Nicolier 
wrote:
>
> Hello,
>
> I'm just a beginner in Racket and want to use the opencv bindings. I have 
> this small basic code :
>
> #! /usr/bin/env racket
> #lang racket/base
>
> (require
>   opencv/highgui)
>
> ; lecture des deux images et affichage (pour tester)
>
> (define imleftname
>   #"./tsukubaleft.jpg")
>
> (define im-left (imread imleftname CV_LOAD_IMAGE_COLOR))
> (imshow "Display window" im-left)
> (define key (cvWaitKey 0))
> (exit 0)
>
> The execution from the shell is ok  but when executing it in the DrRacket 
> console I get this error on (imread imleftname CV_LOAD_IMAGE_COLOR) :
>
> ptr-ref: contract violation
>   expected: (and/c cpointer? (not/c (lambda (p) (pointer-equal? p #f
>   given: #f
>   argument position: 1st
>   other arguments...:
>#
>
> Thanks for your help in advance to understand,
> Frédéric
>
>
>
>

-- 
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 general question

2018-03-30 Thread Alexander McLin
As an aside, vectors are intended to be a constant-time access data 
structure. Lists aren't so it won't make sense to build vectors on top of 
lists which would make for non-constant slot access times.


On Monday, March 26, 2018 at 4:13:02 PM UTC-4, lysseus wrote:
>
>
>
> > On Mar 26, 2018, at 11:03 AM, Eric Griffis  > wrote: 
> > 
> > The `struct` form is defined in `struct.rkt` [1]. As you can see, 
> `struct` wraps `define-struct/derived` [2], which uses many things exported 
> from `struct.c` [3]. The "Inside: Racket C API" doc [5] describes some of 
> these functions -- see section 16. 
> > 
> > On the matter of structs being essentially vectors: Again in `struct.c` 
> [3], the C function `scheme_make_struct_instance` (line 2388) instantiates 
> a `Scheme_Structure`, which is declared in `schpriv.h` [4], line 1113. The 
> field values go into a `slots` array, which points directly to the 
> `Scheme_Object`s (i.e. arbitrary Racket values) supplied to 
> `scheme_make_struct_instance`. Assuming Racket vectors are essentially C 
> arrays, Racket structs are like vectors in this way. 
> > 
> > Looking at `Scheme_Struct_Type`, defined just above `Scheme_Structure` 
> in `schpriv.h` [4], it's clear there's nowhere to store field names. We can 
> confirm this by looking at `_make_struct_type` in `struct.c` [3], starting 
> at line 4778, as this is the function used (indirectly) by 
> `define-struct/derived`. 
> > 
> > Eric 
>
> Thanks, Eric! So maybe the solution for that would not be rewriting the 
> struct definition altogether, but providing that additional information in 
> something equivalent to a le over lambda, which would contain that meta 
> information? 
>
> I ran into an issue that felt similar to this when I was trying to pass 
> method names around in Racket objects. I’ve no idea, but I would think the 
> “solution” to both issues would be similar. Admittedly, I’ve not dug down 
> into either structs or objects deep enough. 
>
> 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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] racket (7) on a new arch

2018-02-23 Thread Alexander McLin
On Friday, February 23, 2018 at 11:08:23 AM UTC-5, David K. Storrs wrote:
>
>
> On Thu, Feb 22, 2018 at 11:14 AM, Alexander McLin  > wrote:
>
>> As one of those who have been following RISC-V progress for several years 
>> and also interested in seeing Racket being ported to that architecture I 
>> want to drop a note to let you know you have my support!
>>
>
> As someone who doesn't know a lot about hardware, I'm curious:  what 
> effect would runningthe new architecture have?  Would it enable new 
> functionality, provide performance boosts...?
>

In the near-future, none. 

RISC-V is designed to be an open-source ISA free of any royalties or 
licensing concerns whatsoever. The idea is to provide a flexible family of 
ISAs which can be combined as needed for one's purposes and any company or 
foundry can manufacture RISC-V CPUs without restrictions. RSIC-V's long 
term goal is to become a universal ISA anyone can use in contrast to X86 or 
ARM which come with hefty licensing fees and restrictions on who can 
manufacture chips which makes it difficult for anyone else to innovate in 
those spaces.

As for enabling new functionality, one major goal for RISC-V is to allow 
the ISA to be extended in well-defined ways which preserve backward 
compatibility but allow innovative features to be enabled for specific 
applications. It remains to see how successful that would be. My 
expectation is better support for hardware-based security features and 
audit of hardware designs by independent parties which is significant given 
how the Meltdown and Spectre vulnerabilities have highlighted the opaque 
nature of the closed-source X86 hardware.

Once anyone who's interested can at relatively low costs explore the design 
space of possible RISC-V hardware, who knows what performance benefits may 
become possible.

-- 
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] racket (7) on a new arch

2018-02-22 Thread Alexander McLin
As one of those who have been following RISC-V progress for several years 
and also interested in seeing Racket being ported to that architecture I 
want to drop a note to let you know you have my support!

-- 
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] Adding interactive overlays to racket plots

2018-02-04 Thread Alexander McLin
Your interactive plot looks wonderful and would be a good replacement for 
some of R's statistical graphing features. I'm excited you're making this 
valuable contribution to Racket.

I did noticed something in your documentation at 
https://alex-hhh.github.io/2018/02/interactive-overlays-with-the-racket-plot-package.html
 
that I felt I should mention. In your histogram section, you have presented 
a graph as a histogram plot, but it's not actually a true histogram plot, 
it's a bar chart.

Histogram plot is a distribution plot of a continuous quantitative variable 
and is designed so the area of the bars sum to 100 percent of the 
distribution. Also it is meaningless for there to be gaps in a histogram 
plot since it is intended to show a continuous distribution.

Bar chart plot on the other hand is meant to show comparison between 
categories and is what is being shown in the documentation section where 
the x-axis represent discreet year categories.

Histograms and bar charts are often confused, likely because they use very 
similar graphical representations but are used to represent very different 
types of data.

A good short explanation is here 
https://www.forbes.com/sites/naomirobbins/2012/01/04/a-histogram-is-not-a-bar-chart/#16dfee8c6d77
 
and it also refers to The Grammar of Graphics by Leland Wilkinson which is 
an excellent source.

Sorry if it seems nitpicky, I've done data processing and analysis and 
often see those kind of issues.

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


[racket-users] Re: Reliably propagating received log messages to ports

2018-02-01 Thread Alexander McLin
Thanks all for your inputs.

I tried `with-intercepted-logged` before though it didn't solve all of my 
issues, though as Robby mentioned, my code probably isn't accurately 
capturing all of the start and exit nuances my need reflect, I'll need to 
think more about the big picture to do a better job of capturing it.

gneuner2, I think your idea combined with either `with-intercepted-logged` 
or `with-logging-to-port` will go a long way towards solving my problem. 
I'm unsure by what is meant by "shutting down the logger" I'm guessing you 
mean associating a will with the logger so when the thread is killed or the 
custodian is shutdown, the will will execute and handle the final log 
cleanup? I guess using Robby's suggestion of using a channel to communicate 
start-up/exit states to a logging subsystem would help in that respect too.

-- 
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] Reliably propagating received log messages to ports

2018-01-31 Thread Alexander McLin
So I am using Racket's logging facilities in a command-line tool I'm 
developing. I have various defined loggers in a sensible hierarchical 
configuration for use as needed.

During the tool's start up period prior to calling the main function I set 
up a log receiver to receive messages at the desired level and place it 
inside a sync loop within its own thread. Each time a sync event is 
received, it is written out to the port, then loop back to waiting for the 
next sync event.

It works reasonably well except I have a new problem, when the tool exits, 
it often exits before the thread handling the log receiver propagation to 
the port has finished receiving all the log events, as a result my logging 
output is frequently truncated.

Given this undesired situation, I need to figure out a better way to 
reliably propagate all log messages to ports before the tool exits normally 
or due to a raised exception.

There is `with-logging-to-port` except I will need to set up multiple ports 
and the idea of wrapping the tool's main body with multiple 
`with-logging-to-port` for each port isn't appealing and it still doesn't 
resolve the problem.

I was wondering if anyone has a better suggestion? Is there a way to detect 
if there are pending log events waiting to be received by the log receiver?

I realize the fundamental nature of my issue is that Racket's logging is 
asynchronous while I want synchronous behavior. I may be better off just 
using old-fashioned `println`s

Thank you for your suggestions.

Alexander McLin

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


[racket-users] Re: How to integrate Racket with a .Net application?

2018-01-31 Thread Alexander McLin
All three approaches you outlined are viable but web service is easiest to 
set up. 

>From what you described, it seems it would be a low-performance use for 
Racket and only simple data structures will be passed back and forth on an 
infrequent basis. Web service would be a good fit for that.

Out of the last two approaches, the COM approach seems to me to be the 
better one. Although I have never used it, Racket provides MzCOM and .NET 
comes with additional support for interacting with COM from within the .NET 
environment. It would allow you to tightly integrate Racket into your 
application, pass complex data back and forth and achieve higher 
performance throughout, but likely it would be more work. I've used COM in 
the past for C++ applications; in those projects it was always a lot of 
work to configure and integrate COM.

I would try setting up a web service first and if it's not adequate for 
whatever reason (performance, business requirements, etc) then I would try 
the COM approach.

-- 
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] Equivalent of dynamic-wind post-thunk for with-handlers

2018-01-24 Thread Alexander McLin

On Wednesday, January 24, 2018 at 5:54:44 PM UTC-5, Alexis King wrote:
>
> Based on your question, why not just use dynamic-wind in combination 
> with with-handlers? Just keep in mind that the post-thunk could be 
> called multiple times if there is a continuation jump into value-thunk, 
> so you should also wrap the whole thing with 
> call-with-continuation-barrier if it’s important that the post-thunk 
> only be executed once. 
>
> Alexis 
>

I was thinking about using `dynamic-wind` but indeed was worried about 
post-thunk being called multiple times. Wrapping with 
`call-with-continuation-barrier` sounds like the right thing to do.

Additionally, the note from Matthias lead me to realize that 
`call-with-exception-handler` is supposed to receive an actual thunk as its 
second argument and `with-handlers` most definitely isn't one. Moving it 
into a thunk resolved the problem so that means in my erroneous code 
`with-handlers` was being evaluated before `call-with-exception-handler` 
even has a chance to install the handler and see the raised exceptions.

Now I just have to think some more about which avenue I want to use.

Thank you for your suggestion!

-- 
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] Equivalent of dynamic-wind post-thunk for with-handlers

2018-01-24 Thread Alexander McLin
I have a with-handlers expression which handles several exceptions 
appropriately and raises user-error exceptions, I have some additional code 
I'd like to be executed after the exception have been handled, analogous to 
dyanmic-wind's post-thunk argument or like the finally clause of a 
conventional try{}catch{}finally{} structure found in other languages.

Documentation has shown that with-handlers and its cousins don't seem to 
have anything like that so I thought I'd wrap my with-handlers expression 
in a call-with-exception-handler to intercept the raised user-error 
exceptions, do additional processing and returns the exception to continue 
its propagation. It's not working and the installed exception handler 
doesn't seem to be called at all.

Here's simplified code.

(call-with-exception-handler 
   (lambda (e) 
 ...do more work 
 e) 
(with-handlers ([exn:a? (lambda (e) (raise-user-error "exception exn:a 
caught"))] 
  [exn:b? (lambda (e) (raise-user-error "exception 
exn:b caught"))]) 
  ...code that may throw either exn:a or exn:b ))

My expectation was that the lambda installed by the 
call-with-exception-handler would run after each user-error is raised. I do 
see the user-error exceptions' messages being printed in the terminal so 
they're being propagated all the way to the uncaught exception handler but 
no work is being done by my own lambda handler. What am I doing wrong? More 
to the point, is there a better way to do post with-handlers exception 
handling processing?

My thinking is that I have a flawed understanding of the meaning of dynamic 
extent of with-handlers and call-with-exception-handler forms.

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


[racket-users] Re: Installing Racket Package `gregor` inside a Docker container

2017-12-27 Thread Alexander McLin
I don't have much to add but wanted to note that the problem appears to be 
in rendering grengor's documentation. The package itself may be installed 
fine, just not its associated documentation. You can test to verify if 
package is installed by querying via raco pkg or just requiring gregor in a 
test file and running it.

Depending on your needs, it may not be a big deal if your Docker doesn't 
have the package documentation available.

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


[racket-users] Re: New package: Argo: JSON Schema validation

2017-08-30 Thread Alexander McLin
This is quite a timely post. I had been looking into using a JSON schema 
validation C library and using FFI to hook into that for my projects.

I'll give your new package a try!

Thank you for making it available Jesse.

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


[racket-users] Re: query-exec SQLite3 multiple statements

2017-07-28 Thread Alexander McLin
Yes, you can use DrRacket to debug the file at 
collects/db/private/sqlite3/connection.rkt. That one is likely the most 
relevant one for you.

Alternatively, you could wait till Racket 6.10 is released which is very soon I 
think. The bug fixes to the db library might reveal the correct error message 
being generated by SQLite3.

> 
> It works, but I'd still like to figure out exactly what's wrong. I'm 
> relatively new to racket, is it possible to debug the standard library to see 
> whats going wrong?

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


[racket-users] Re: query-exec SQLite3 multiple statements

2017-07-26 Thread Alexander McLin
I tried query-exec on those SQL strings you posted on gist on my local copy of 
Racket 6.8 with an in-memory SQLite3 db and it worked fine.

I'm not sure what's causing your issue. What version of Racket and SQLite3 are 
you running on your machine? Is it Windows, Linux, or Mac OSX?



> https://gist.githubusercontent.com/abramsba/54de32406917e5fb0c480d9c214c3b08/raw/e7c0001ba19d211e856a4458316b391e77d0e530/query.sql
> 
> https://sqliteonline.com/#fiddle-5978e22b51dfap6hj5lcvher
> 

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


[racket-users] Re: query-exec SQLite3 multiple statements

2017-07-26 Thread Alexander McLin
One more thing for you to check, make sure there's no trailing whitespace after 
the end of your statement's terminating semi-colon, that will also trigger the 
`multiple statements given` error. That bug has been also fixed in the current 
repository.

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


[racket-users] Re: query-exec SQLite3 multiple statements

2017-07-26 Thread Alexander McLin
It appears you're giving to `query-exec` a string consisting of two statements; 
the create table and insert into statements. `query-exec` only supports 
executing one statement at a time.

If you break your two statements up into two strings and call `query-exec` on 
each one, it should work.

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


[racket-users] Re: Searching diffrences in two lists

2017-06-28 Thread Alexander McLin
Consider using the following function 
https://docs.racket-lang.org/reference/pairs.html?q=memq#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._memq%29%29

It's helpful to sketch out the general steps you'd need to be able to carry out 
the procedure to solve the problem.

My quick sketch would look like the following:

Since you are checking to see if an element in the first list is also in the 
second list, you'd need to be able to take one element from the first list and 
check to see if it is a member of the second list, then repeat again for each 
of the remaining first list's elements.

How would you code the above procedure?

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


[racket-users] Re: inspecting a table error 'error 'query: multiple statements given'

2017-06-25 Thread Alexander McLin
FYI, the misleading "multiple statements given" error has been fixed in the 
racket master branch and correct syntax error message is now being raised.

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


[racket-users] Re: Executing batch statements against a database using `db` library.

2017-05-12 Thread Alexander McLin
Thank you Alex, your code looks comprehensive and ought cover my use case. 
Appreciate your sharing!

Best,
Alexander 

-- 
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] Executing batch statements against a database using `db` library.

2017-05-12 Thread Alexander McLin
`db` library doesn't seem to provide support for executing batch statements 
against a database. I'm trying to initialize and create an in-memory SQLite3 
database using a SQL schema file. `query-exec` and its friends only support 
executing single SQL statements. 

Reading documentation isn't showing me a way to be able to execute more than 
one statement at once or allow a SQL text file to be read in and executed. Does 
anyone know a better method?

Thanks!

Alexander B. McLin

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


[racket-users] Re: Racket Package Catalog Site and Raco Commands

2017-04-24 Thread Alexander McLin
While I have no strong preferences for whether it would be better to allow 
end-users determine what tags to apply as opposed to automatic system tags, it 
might be more effective to make provisions for special tags to be supported in 
info.rkt and have the catalog automatically read those tags if they are 
present. Developers and maintainers are already in a good position to furnish 
well chosen tags prior to uploading to pkgs.racket-lang.org.



On Monday, April 24, 2017 at 3:08:24 PM UTC-4, Jack Firth wrote:
> A `raco` tag for all packages that add raco commands is a great idea. I don't 
> think we should build some sort of system tag that's automatically added 
> though; I'd much rather have some way of granting "tagging rights" to a set 
> of catalog users and let them figure out what tags are appropriate for the 
> variety of packages we have today. Not all sensible tags will have automatic 
> means of detection. Here's a sample list of tags I'd like to have used 
> consistently across the catalog:
> 
> - raco: provides a raco command
> - testing: provides something useful for testing code
> - data: provides a data structure of some sort
> ...

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


[racket-users] Re: Racket Package Catalog Site and Raco Commands

2017-04-24 Thread Alexander McLin
All of your suggestions are great and get my vote.

To elaborate on the raco tag, it should list all the commands *and* subcommands.

Example:

pkg package

tag: raco: pkg install, pkg update, pkg remove, etc.


-- 
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] Racket Package Catalog Site and Raco Commands

2017-04-24 Thread Alexander McLin
First of all, I wish to express my appreciation for such a beautifully designed 
package catalog site located at pkgs.racket-lang.org.

I was wondering if we could add a special search term category or tag that list 
all available raco commands that packages may install?

For example, when building a minimal Racket for deployment to a production 
environment, I also wanted to include the test command. It took trial and error 
to figure out that the compiler package is responsible for installing the test 
command. It's not apparent from information available on the package list and 
the README linked to from the compiler package's Docs reference doesn't mention 
it.

And last but not the least.

The main page of the package catalog lists 738 packages which is a long list 
indeed and will grow without bound - which is a good problem to have! Search 
terms often still return hundreds of hits. May paging be added to reduce the 
list to manageable chucks? Something like the DataTable plugin for jQuery which 
implements client-side paging. Cf. https://www.datatables.net/ 


Best,
Alexander

-- 
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] Announcing Leibniz, a new language in the Racket universe

2017-04-20 Thread Alexander McLin
> Indeed. What would be such classical papers from your field?

One paper I have in mind is Hodgkin & Huxley's paper published in 1952 where 
they first wrote down the equations describing the membrane voltage of the 
giant squid axon. 
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC1392413/pdf/jphysiol01442-0106.pdf

It'll be a good exercise for me to go through it and write a summary, 
transcribing the equations into the Leibniz notation.
 
> I have vaguely played with that idea myself, but I don't know the
> capabilities of today's proof assistants well enough to judge how they
> could be used in the evaluation of scientific models. Do you have
> a concrete application in mind? Something that could be done today
> if the learning-curve issue could be overcome?

Currently I only have a limited exposure to proof assistants, so I hesitate to 
say anything definitive. I'm focusing on Isabelle right now at tutorial stage 
since I heard from various sources that HOL-type assistants are more useful for 
real analysis problems. Isabelle belongs to that category which is the reason 
I'm looking at it more closely.

No firm concrete applications in mind, it's an open-ended exploration.

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


[racket-users] Re: [Shameless self-promotion] Articles about programming-language theory for working programmers in Racket

2017-04-17 Thread Alexander McLin
Leandro,

Your article comes at a good time for me because I received my copy of 
"Semantics Engineering with PLT Redex" last week and am preparing to start 
studying it. I thought your examples are a nice exposition of the complex ideas 
that go into selecting features a programming language needs to support.

I thought the bicycle trip example illustrates nicely the tension between 
balancing simplicity and convenience, and reminds me simplicity isn't 
necessarily helpful.

As a working programmer earning his daily bread, I typically deal with complex 
and messy cases where programming convenience is preferred over simplicity but 
being able to step back and seeing the abstract principles underlying tools I 
use is helpful. 

My main take away from your article is that there are important features that 
come together to make a programming language function as a system for 
supporting effective abstractions to help formulate and solve computing 
problems.

As you emphasized in the article, it is very interesting how certain formal 
systems very different from each other are equivalent in terms of computational 
power and ultimately reduce to communication and data. That reinforces the 
insight that what a typical working programmer does is essentially formulating 
communication plans as data to be read and executed by a computer.

On a final note, I noticed with a pleasant surprise that you are at JHU, as it 
happens I am staff affiliated with JHU under Krieger. It's nice to see there is 
another Racketeer on Homewood!

I look forward to reading more of your articles in the future.

- Alexander

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


[racket-users] Re: inspecting a table error 'error 'query: multiple statements given'

2017-04-17 Thread Alexander McLin
The error message is unclear but I believe SQLite do not support parameters for 
PRAGMA statements.

The SQLite documentation at http://www.sqlite.org/lang_expr.html#varparam  
specifically says parameters are supported by expressions. PRAGMA statements 
are not expressions. 

If you examine the SQL syntax structure defined for expressions at 
http://www.sqlite.org/lang_expr.html, you'll see PRAGMA is not part of the 
definition.

If you execute the following: (query db "PRAGMA table_info($1)"). It generates 
the same error without any parameter arguments being passed along. It makes me 
think the error may be arising from an internal parsing error and probably 
could be improved on.

-- 
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] Announcing Leibniz, a new language in the Racket universe

2017-04-16 Thread Alexander McLin
This looks quite promising, I'm liking the progress and examples so far. The 
idea of using the same notation to express both equations and algorithms 
excites me. It would certainly make it easier to write down and analyze 
algorithms implementing a set of model equations in a language independent 
manner.

I have personal interests in computational science and executable biological 
models, rewriting some classical papers' models into the Leibniz notation would 
definitely be a good aid for study and understanding.

One thing I'm wondering about; for a long time I've been curious about the idea 
of using proof assistants to help explore logical consequences of different 
equation choices in some modeling problem, but proof assistants come with 
intimidating interfaces with steep learning curves. The Leibniz notation looks 
like it could serve as a user friendly format which can be automatically 
translated into something a proof assistant understands.

I'm not sure how practical that would be, it's too early in my understanding of 
Leibniz's benefits, there's still more to read, including Maude documentation.

Nevertheless, thank you for making this project a reality.

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


[racket-users] Re: linking with raco ctool : unable to find libracket3mxxxxxxx.lib

2017-03-14 Thread Alexander McLin
You need to compile Racket from source to generate the .lib file, it is not 
distributed with the installation.

You need to make sure the source is the same version as your installed Racket 
and it is compiled targeting the same bit architecture as the installed Racket 
version. Then copy the generated .lib file to the Racket installation's lib 
directory. The directory's location depends on your operating system.

-- 
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] Request for Information about Racket and .NET interop support

2017-01-16 Thread Alexander McLin
I understand where you're coming from. My organization is flexible and isn't 
ideologically committed to one particular platform. Microsoft's community 
promise is just that, a promise. It can be changed or revoked at any time in 
the future.

I've been encouraging adoption of open system practices and tool diversity in 
my organization. I believe Racket will bring value for my particular needs. I 
think, although I freely admit I am not sure, that there is a benefit to 
creating a .NET package for Racket. Will the benefits justify the development 
investment? I don't know. It seems a worthwhile area to explore.



On Monday, January 16, 2017 at 2:11:11 PM UTC-5, Neil Van Dyke wrote:
> This doesn't help anyone who's committed fully to a platform, but if one 
> is not, or when one has the opportunity to evolve, it should be mentioned...
> 
> When an organization emphasizes real open systems (which currently 
> probably means HTTPS Web services, talking in XML or JSON, and perhaps 
> SQL, all according to well-defined schema), it's easier to interoperate 
> with most any platform -- current and future, including all mainstream 
> languages, innovative new languages, pure Web browser JavaScript, iOS 
> apps, Android apps, and whatever comes along next.
> 
> (Just because a platform has a standards document, or an open source 
> implementation was arranged, doesn't mean a platform wasn't created as a 
> proprietary business move, with much of the usual implications.)

-- 
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] Request for Information about Racket and .NET interop support

2017-01-16 Thread Alexander McLin
Thank you Matthias for the historical information, it was interesting to learn 
that a porting project was sponsored by Microsoft in .NET's early days. Were 
any papers describing the efforts published?

Porting Racket to .NET definitely is ambitious and as you have said, it seems 
unlikely .NET has evolved enough to make it a feasible proposition.

My plan is to load the CLR into Racket's process as a separate foreign library 
and interact with it through a suitable interface. It's easy to load and call 
basic .NET managed functions using Racket's ffi library, it only takes three or 
four lines of code to accomplish a basic Hello, .NET World program. But an 
interop layer needs to be built to get any useful mileage out of it.

So far my current design idea is to create proxy objects on Racket's side which 
forward calls to actual .NET objects but otherwise behave like standard Racket 
objects. We'll see how well that works.

I will be happy to report on my progress.




On Monday, January 16, 2017 at 10:08:17 AM UTC-5, Matthias Felleisen wrote:
> MS asked us (mostly NEU) to investigate a port of Racket (then PLT Scheme) to 
> .Net some 15 years ago. (They supported the 4-year project with a generous 
> financial donation.) In the end, we had to admit defeat. Racket’s GUI 
> framework (e.g, event spaces), its mapping to the control stack (continuation 
> marks), and a few other niceties that we really enjoy (but could live 
> without) got in the way. 
> 
> Since then, both Racket and .Net have evolved, but I am afraid, not enough to 
> make a full-fledged port easy. 
> 
> Now, if you can live with separate Racket and .Net processes that communicate 
> via a COM or ActiveX-like interface, that might be doable. We do have COM 
> packages and have used them extensively. As far as I know, nothing like that 
> exists. 
> 
> Please continue to report on your efforts — 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.


[racket-users] Request for Information about Racket and .NET interop support

2017-01-15 Thread Alexander McLin
Dear Racketeers,

I've been using Racket on and off for small-scale private projects over several 
years. Unfortunately the majority of my development work has been based on .NET 
Framework as part of my daily job. 

I'm interested in incorporating Racket into my software stack but I need to be 
able to support interoperating with Microsoft services in use in my 
organization.

I'm considering developing a package designed to create and manage .NET objects 
and services from within Racket. For the past several weeks I've been doing 
exploratory work with Racket's ffi/unsafe library and .NET CLR's low level 
plumbing to understand what would be required to create a such package. It's 
all very preliminary right now and much design work remains to be done.

The Pythonnet project serves as an existing example of a similar type of 
package.

Before I get too deep into this, I'm doing my due diligence. I did a keyword 
search of Racket's package catalog and the users mailing list archives but 
didn't find any existing prior work along similar lines. I did find a thread 
from 2011 asking about .NET support. 

I'm asking on the list if anyone has done or know of any similar work? 
Currently I'm starting from scratch but would like to avoid unnecessary 
duplication of efforts if I can help it. Appropriate credit will of course be 
given.

Because .NET is object-oriented, therefore code written for that platform is 
designed along the lines or compiled to OO semantics — see C# versus F# — my 
current idea is to create a Racket API using Racket's own class system to map 
to .NET classes. The .NET OO semantics are similar enough to Racket's system I 
think it can be adapted to interface with .NET without too much impedance 
mismatch.

Any design ideas or suggestions are very much welcome.

Best,
Alexander McLin

-- 
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 users fight for their right to colon keywords

2015-11-24 Thread Alexander McLin
I remember those classes as a student, to be honest I didn't really actually 
started to learn till after I'd left undergraduate.

Don't get me wrong, I know how frustrating syntax/semantics nuances can be.

I've been reflecting on the idea of existential keywords the past couple days 
and have realized that they complicate the situation more than their worth, so 
please consider this my formal withdrawal of support. I'm fine with just 
passing #t/#f to a keyword, it's crystal clear and consistent with everything 
else.

In interest of peace, I offer you this tidbit; in the future if I ever send you 
code, I'll first run it through the clan-of-colons meta-language so you'll only 
see nice :keywords throughout the code.

Aλexander



On Monday, November 23, 2015 at 5:30:40 AM UTC-5, Neil Van Dyke wrote:
> The Clan of Colon Keywords was willing to honor a truce.
> 
> > I think for people coming from other  languages with :keywords, Racket's 
> > #:keywords help to signal that they are not anything like how :keywords are 
> > usually used.
> 
> I'm sure there are relatively better justifications for pound-colon than 
> signaling nuances to people in their first 10 seconds of being exposed 
> to a new language, than by encumbering the syntax for everyone, for all 
> time.  After those first 10 seconds, you've had time to tell this 
> totally-new person from another language, "Racket keywords are somewhat 
> different from keywords in your other language (in a way that is not 
> worth pointing out at this early point, so sorry for the confusion, 
> please forget we even said anything, just assume for now that keywords 
> are similar to the keyword arguments you already know, because they are, 
> and let me tell you about the more important things for now)."
> 
> (That said, in a particular kind of undergrad CS curriculum, in which 
> numerous languages are thrown at students, one language after another, 
> with students to be tested on language trivia, with little time to begin 
> to actually learn any of the languages in a meaningful way... then, 
> sure, teaching-to-the-test, one might make the subtly-different keyword 
> arguments appear different between two languages, to help prepare 
> students for the all-important test question, "How do keywords in Racket 
> differ from keywords in Common Lisp?"  I shall not be complicit in that 
> atrocity.  Fortunately, I'm not aware of anyone teaching Racket like that.)
> 
> >   I'd love to see existential/toggle keywords.
> 
> Besides greatly changing how parsing could work (and complicating human 
> code reading of procedure applications, for the same reason that parsing 
> might have to do a lookup), imagine a common usage scenario... Procedure 
> A shares some of its signature with procedure B, and procedure A calls 
> B, passing some of its A's actual arguments to B.  Compare the code for 
> "passing through" Boolean arguments using existential and 
> non-existential keywords, especially the combinatorial explosion (or 
> need for dynamic list apply) when more than one argument is Boolean.
> 
> 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.


[racket-users] Re: racket users fight for their right to colon keywords

2015-11-22 Thread Alexander McLin
Upon some reflection, I realized that the existential proposal as outlined in 
my earlier reply introduces an ambiguity into the keyword system. Since 
keywords can be used in any position relative to any actual positional 
arguments, there'd be no way to distinguish an existential keyword followed by 
a positional argument from an existential keyword followed by a value intended 
to be passed to that keyword.

So either the proposal is amended to disallow any values being passed to an 
existential keyword or just drop the idea. I admit I feel uneasy about allowing 
a special boolean case in the keyword grammar when all other keyword cases are 
allowed to assume arbitrary values.


Aλexander


On Sunday, November 22, 2015 at 12:08:49 PM UTC-5, Alexander McLin wrote:
> I don't really have a horse in this race. My position is very similar to 
> Alexis which is why I didn't vote in the poll too. When I first arrived to 
> Racket the #: syntax made me go "what in the world?" Since then I've grown to 
> appreciate the reasoning behind the deliberate eye catching keyword syntax. 
> 
> I appreciate that Racket takes a principled approach to making language 
> concepts precise and avoid muddling together distinct purposes as many other 
> languages do. Racket keywords are just that, syntactic tags denoting function 
> application arguments no more no less. I think for people coming from other  
> languages with :keywords, Racket's #:keywords help to signal that they are 
> not anything like how :keywords are usually used.
> 
> Honestly I think that an alternative keyword syntax should not be in the base 
> language, the ship has already long since sailed and it would be a mistake to 
> try to reverse course and fix it for sake of aesthetics. Racket already uses 
> # to suggest syntax specialness, like #t, #f, #', #(), #<>, #lang. To me, #: 
> seems to naturally fit into that category.
> 
> It would be far better to put the alternative in a meta-language that people 
> can choose to use or not. Concerns about snippets containing :keywords posted 
> to social media and elsewhere leading to confusion also apply equally to 
> snippets of other non-base languages. I've seen several cases of scribble and 
> other snippets being posted without #lang supplied and if I tried blindly 
> running them directly in Racket, I'd get errors. If anything this should 
> remind us that providing #lang is mandatory, not optional and adjust our 
> habits to be more careful in the future when posting to social media.
> 
> Now that's been said, I'm with gneuner2. I'd love to see existential/toggle 
> keywords.
> 
> If I may tweak his proposal a bit, something like 
> 
> (define (foo #:keyword (id)) (if (id) 'foo 'bar))
> 
> Basically if an identifier just by itself is given in the list immediately 
> following the keyword, then it's treated as boolean. When keyword is supplied 
> in a function call, then id evaluates to #t otherwise it's #f. If someone 
> provides a value with the keyword - which does not presents an issue - id 
> will be bound to that value which will still be treated as truthy, unless the 
> value happens to be #f.
> 
> So based off the grammar from Racket Reference for define 
> http://docs.racket-lang.org/reference/define.html
> 
> We'd be adding another clause to the arg production rule.
> 
> arg   =   arg-id
>   |   [arg-id default-expr]
>   |   keyword arg-id
> |   keyword [arg-id]
>   |   keyword [arg-id default-expr]
> 
> 
> Aλexander
> 
> 
> 
> On Saturday, November 21, 2015 at 6:06:58 PM UTC-5, gneuner2 wrote:
> > Coming late to this.
> > 
> > On Wed, 14 Oct 2015 11:50:41 -0400, Neil Van Dyke
> >  wrote:
> > 
> > >We are conducting a highly scientific poll.
> > >
> > >The question we want to answer is whether people would like for the 
> > >Racket standard languages to have symbols that begin with the colon 
> > >character (except for the symbol `:`) to read the same has keywords that 
> > >begin with pound-colon.
> > 
> > I actually prefer the #: syntax, but what I would like is support for
> > "existence" keywords - i.e. keywords with no argument - where the only
> > thing you care about is whether or not the keyword was provided.
> > 
> > Obviously, this can be done using a "rest" argument and symbols, but
> > the #: syntax draws attention that other symbols do not because
> > DrRacket, at least by default, colors keywords differently from other
> > symbols.
> >

[racket-users] Re: racket users fight for their right to colon keywords

2015-11-22 Thread Alexander McLin
I don't really have a horse in this race. My position is very similar to Alexis 
which is why I didn't vote in the poll too. When I first arrived to Racket the 
#: syntax made me go "what in the world?" Since then I've grown to appreciate 
the reasoning behind the deliberate eye catching keyword syntax. 

I appreciate that Racket takes a principled approach to making language 
concepts precise and avoid muddling together distinct purposes as many other 
languages do. Racket keywords are just that, syntactic tags denoting function 
application arguments no more no less. I think for people coming from other  
languages with :keywords, Racket's #:keywords help to signal that they are not 
anything like how :keywords are usually used.

Honestly I think that an alternative keyword syntax should not be in the base 
language, the ship has already long since sailed and it would be a mistake to 
try to reverse course and fix it for sake of aesthetics. Racket already uses # 
to suggest syntax specialness, like #t, #f, #', #(), #<>, #lang. To me, #: 
seems to naturally fit into that category.

It would be far better to put the alternative in a meta-language that people 
can choose to use or not. Concerns about snippets containing :keywords posted 
to social media and elsewhere leading to confusion also apply equally to 
snippets of other non-base languages. I've seen several cases of scribble and 
other snippets being posted without #lang supplied and if I tried blindly 
running them directly in Racket, I'd get errors. If anything this should remind 
us that providing #lang is mandatory, not optional and adjust our habits to be 
more careful in the future when posting to social media.

Now that's been said, I'm with gneuner2. I'd love to see existential/toggle 
keywords.

If I may tweak his proposal a bit, something like 

(define (foo #:keyword (id)) (if (id) 'foo 'bar))

Basically if an identifier just by itself is given in the list immediately 
following the keyword, then it's treated as boolean. When keyword is supplied 
in a function call, then id evaluates to #t otherwise it's #f. If someone 
provides a value with the keyword - which does not presents an issue - id will 
be bound to that value which will still be treated as truthy, unless the value 
happens to be #f.

So based off the grammar from Racket Reference for define 
http://docs.racket-lang.org/reference/define.html

We'd be adding another clause to the arg production rule.

arg =   arg-id
|   [arg-id default-expr]
|   keyword arg-id
|   keyword [arg-id]
|   keyword [arg-id default-expr]


Aλexander



On Saturday, November 21, 2015 at 6:06:58 PM UTC-5, gneuner2 wrote:
> Coming late to this.
> 
> On Wed, 14 Oct 2015 11:50:41 -0400, Neil Van Dyke
>  wrote:
> 
> >We are conducting a highly scientific poll.
> >
> >The question we want to answer is whether people would like for the 
> >Racket standard languages to have symbols that begin with the colon 
> >character (except for the symbol `:`) to read the same has keywords that 
> >begin with pound-colon.
> 
> I actually prefer the #: syntax, but what I would like is support for
> "existence" keywords - i.e. keywords with no argument - where the only
> thing you care about is whether or not the keyword was provided.
> 
> Obviously, this can be done using a "rest" argument and symbols, but
> the #: syntax draws attention that other symbols do not because
> DrRacket, at least by default, colors keywords differently from other
> symbols.
> 
> Although the keyword syntax coloring still works with a tick before a
> symbol that looks like a keyword, having to remember the tick is a
> PITA when you are thinking of the symbol as a keyword.  If you forget
> it, you get a  nasty
> "application: missing argument expression after keyword"
> error.
> 
> 
> How much trouble would it cause to allow naked keywords and provide a
> predicate based on their name?  E.g.,
> 
> (define ( test blah #:opt #:req req )
>:
>   (when #:opt?  ... )
>:
>   )
> 
> (test #:req 3)
> (test #:req 42 #:opt)
> 
> Or even something like  (define ( test blah #:opt [] #:req req ) which
> makes it more obvious that the keyword is only there to be tested?
> 
> George

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


[racket-users] Re: Emacs Lisp as a Racket Language?

2015-07-03 Thread Alexander McLin
No question, this would be a challenging project.

Do a clean room fresh implementation or provide full Emacs Lisp compatibility? 
Would it make sense to consider doing a strict subset of Emacs Lisp, with 
sufficiently flexibility to allow popular extensions run while leaving others 
behind?

Common Lisp tried a clean room approach a long time but unfortunately it ended 
up languishing. They had some very interesting ideas based on an interface 
framework that I understand were heavily inspired by Geneva Symbolics Dynamic 
Windows.

Their attempt, Climacs https://common-lisp.net/project/climacs/ which was based 
on https://en.wikipedia.org/wiki/Common_Lisp_Interface_Manager

>From what I've seen so far, it appears they generalized the buffer idea to 
>handle arbitrary data, both text and graphics in a more systematic way. They 
>had an example of browsing a file system with all the file icons and clickable 
>expandable nodes right within the buffers.

Worth it checking to see if their ideas can be reused.


On Thursday, July 2, 2015 at 3:36:47 PM UTC-4, Greg Davidson wrote:
> Is there interest in creating a Gnu Emacs Lisp Racket Language, along with 
> the underlying APIs (perhaps tied to DrRacket) sufficient to compile and run 
> Gnu Emacs Lisp extension packages?  Is there prior or ongoing work for such a 
> project?
> 
> For some years there has been an attempt to port Gnu Emacs to run under Guile 
> Scheme.  A big stumbling block is the vast amount of extensions written in 
> Emacs Lisp and continuing development thereof.  Racket seems to be a *much* 
> better platform for such a project than Guile, don't you think?
> 
> _Greg (a long-time ambivalent Emacs user tired of Emacs Lisp)

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


[racket-users] Re: Gear VR

2015-07-01 Thread Alexander McLin
On Wednesday, July 1, 2015 at 7:07:03 AM UTC-4, AJ Campbell wrote:

> JSON is probably going to be the go-to format to send/receive renderable 3D 
> packets.  The thought of doing it with XML makes me feel ill. I'm sure Racket 
> can handle JSON data (it very well might already for all I know), but 
> Javascript found its way across the whole stack (among other reasons) because 
> we love the idea of having a universal language to eliminate the 
> serialization between client and server, plus it knocks down communication 
> barriers between front-end and back-end team members.

I'm one of those who really wish Javascript hasn't spread across multiple 
stacks. I also question the effectiveness of having an universal language 
represented by JavaScript used for front-end and back-end. As a person who 
regularly juggles both modes in his daily job, the APIs and execution models in 
two cases are very different and result in mental context-switch costs 
regardless of whether they use the same language or not.

Personally I think team members would be better off communicating via design 
planning and documentation rather than relying on whether languages they use 
for respective project areas happen to coincide.

I also have serious questions about long-term viability of JavaScript now that 
WebAssembly has been announced. Once it's mature, I suspect JS will be 
abandoned or at least usage severely reduced with corresponding drop in support 
in other stacks.

The irony is WebAssembly is designed to be a compressed abstract syntax format! 
Essentially S-Expressions in a different disguise, so you can argue that 
Racket/Lisp is already well positioned to target WebAssembly directly for web 
apps.

I figure that Racket is probably better suited as a "universal language" since 
it's possible to implement languages in it to fit whatever demands diverse 
developers or problem domains have, including creating 
non-S-expression-oriented languages.

I do realize business considerations have an important impact on what tools are 
selected, and John Carmack needs to be able to reach a large audience of 
regular and technical users. I hope he will be able to leverage Racket or 
preferred Scheme variant to accomplish that.

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


Re: [racket] universe program using 100% cpu on Mac (also poor Raspberry Pi performance)

2014-12-30 Thread Alexander McLin
Hello Darren,

May I offer this point of view regarding tautological tests. They are useful 
for checking if your assumptions are consistent and they stay that way over 
multiple iterations of design modifications.

Personally I've found keeping a list of assumptions only in my head is a recipe 
for design errors. Fallible memory and poorly thought out logical consequences.

Several times I've found simple seeming functions had surprising edge cases I 
hadn't thought about until I actually wrote down simple obvious tests. So they 
are useful for making the brain juices flow while you are starting to get the 
shape of your program down pat.

Tests really serve two functions here, verification of correctness and whether 
the design makes sense. They are both for you and your end users. I think 
tautological tests are more for your benefit than the end users.

Tautological tests in this case have a useful purpose of  allowing you to try 
your design out in practice and deciding if it works in a general sense of 
practicality and effective interface regardless of whether it gives correct 
output.

> On Dec 29, 2014, at 11:28 PM, Darren Cruse  wrote:
> 
> Hi Matthias just saw your reply.
> 
> Regarding the tests I like what you said about "for a large function -- a 
> reader quickly gets the idea of how the function works from reading some 
> tests".
> 
> But if I'm honest the example that you gave is the kind of example that 
> bothers me - in that it's *not* a large function.  The test you gave reminds 
> me of the majority that I see - and it struck me recently I think what 
> bothers me is that such tests are in effect a tautology
> 
> i.e. most of these tests like this, esp. since they are written by the same 
> programmer writing the function under test, are literally just a restating of 
> the exact same assumptions the programmer has made in writing the function.  
> So they are *literally* redundant.  Yet they must be maintained as the 
> programmer maintains and modifies the code going forward.  So there is a cost 
> to them, but to me I honestly don't see much if any benefit.
> 
> Which isn't to say that good tests can't be written if they are testing a 
> large and complex function (as you said).  What I question is the common 
> belief nowadays that they're always of value even in simple cases. 
> 
> Anyway hope you'll forgive my heresy.  I turned 50 this year maybe I just an 
> old dog now too set in his ways.  I know I'm very much in the minority in 
> this view.  No offense intended.
> 
> But more to the point - here's what I did while I should have been writing 
> tests:
> 
> pong-world.rkt via whalesong  :)
> 
> The biggest challenge - other than what looks like some problems with 
> multiple/deeply nested overlay/place-image positioning, is that whalesong 
> seems to not support "on-release", so for now this works best if you click 
> and hold where it says "hit space to serve" and then you can use your mouse 
> and play the game against yourself.
> 
> This was done using the soegaard/whalesong version of whalesong btw.
> 
> Darren
> 
> 
> 
> 
>> On Mon, Dec 29, 2014 at 8:00 PM, Matthias Felleisen  
>> wrote:
>> 
>> TESTS: Say I want to eliminate a common pattern from your handle-key-down 
>> function. If it comes with some tests, four to be precise, a simple run -- 
>> without playing -- assures me of basic qualities. If you express tests like 
>> those below and you formulate them first, you get an idea of how to code the 
>> function. And -- for a large function -- a reader quickly gets the idea of 
>> how the function works from reading some tests. 
>> 
>> (check-expect (handle-key-down initial-state "w")  (set-left-moving 
>> initial-state UP-DIR))
>> 
>> (define (handle-key-down world a-key)
>>   (cond
>> [(key=? a-key "w") (set-left-moving world UP-DIR)]
>> [(key=? a-key "s") (set-left-moving world DOWN-DIR)]
>> [(key=? a-key "up") (set-right-moving world UP-DIR)]
>> [(key=? a-key "down") (set-right-moving world DOWN-DIR)]
>> [else world]))
>> 
>> (define (set-left-moving world dir)
>>   (set-left-paddle world (set-paddle-moving (pong-world-left-paddle world) 
>> dir PADDLE-SPEED)))
>> 
>> (define (set-right-moving world dir)
>>   (set-right-paddle world (set-paddle-moving (pong-world-right-paddle world) 
>> dir PADDLE-SPEED)))
>> 
>> 
>> GAME PAD: I am happy to see that you used on-pad. Your game does give me an 
>> idea on how to improve the whole 'pad situation'. 
>> 
>> -- Matthias
>> 
>> 
>> 
>> 
>> 
>>> On Dec 29, 2014, at 1:43 PM, Darren Cruse wrote:
>>> 
>>> Thanks Matthias and it will be quite fun to tell the others at my next 
>>> meetup who code reviewed this for me! :)
>>> 
>>> I'll make the changes you suggested though (forgive me) I'll have to think 
>>> about what constitutes useful tests for this.  Somehow I've never fully 
>>> bought into TDD though I know I'm one of the last holdouts in the civilized 
>>> world. :)  Can I get out of it saying I was

Re: [racket] SICP (again)

2014-11-26 Thread Alexander McLin
There is some differences between Racket and MIT-Scheme though I don't think 
it's such a major difference to be a problem.

There is also a Racket SICP compatibility package that makes it more conforming 
to the book. It's available in the package catalog. I haven't used it so I 
don't know whether it works or not but it's worth a look.

> On Nov 26, 2014, at 8:00 AM, Catonano  wrote:
> 
> 
> 
> 2014-11-26 13:17 GMT+01:00 Alexander McLin :
>> The square function is also defined in earlier SICP sections so I would 
>> recommend you maintain a running file of all functions SICP defines so you 
>> can refer back to them easily.
> 
> Ok, this seems a reasonable approach. Note taken, thanks
> 
> Are there any specific advices you'd give in order to follow the SICP on 
> Racket ?

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


Re: [racket] SICP (again)

2014-11-26 Thread Alexander McLin
The square function is also defined in earlier SICP sections so I would 
recommend you maintain a running file of all functions SICP defines so you can 
refer back to them easily.



> On Nov 26, 2014, at 5:37 AM, Catonano  wrote:
> 
> Hello 
> 
> I understand that this is not the first time someone asks about using Racket 
> for a SICP study group.
> 
> I used the not so mantained mit-scheme compatibility package and I tried to 
> paste this piece of code
> 
> 
> 
> (define (average x y)
> (/ (+ x y) 2))
> 
> (define (sqrt x)
> (define (improve guess)
> (average guess (/ x guess )))
> (define (good-enough? guess)
> (< (abs (- (square guess) x )) .001))
> (define (try guess)
> 
> (if (good-enough? guess)
> guess
> (try (improve guess
> (try 1))
> 
> 
> It should be the Newton's method to calculate the square root
> 
> We copied it from the lectures
> 
> In this code we use the "square" function. In mit-scheme it's ok, in Racket 
> it's not defined
> 
> Should I import any module ?
> 
> Are common functions named as in mit-scheme ? Or are we gonna run into 
> compatibility issues ?
> 
> Thanks for any hint
> 
>  Racket Users list:
>  http://lists.racket-lang.org/users


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


Re: [racket] Understanding contracts

2014-10-03 Thread Alexander McLin
Making a correction here, my wish error message should say this.

* in: the 1st argument of*
*   (->**
*((and/c number? (between/c 0 1)))*
*(#:clamp-range boolean?)*
*number?)*

Because I understand that the phrase *"the range of"* means the last item
in the -> form which is the ->* contract.

On Fri, Oct 3, 2014 at 10:55 PM, Alexander McLin 
wrote:

> Actually I wasn't quite ready to move on.
>
> When I apply (curve 3) where (define curve (cubic-bezier a b) a and b are
> bezier-control-point?
>
> I get the following contract error:
>
> ---
> *(curve 3)*
> *. . cubic-bezier: contract violation*
> *  expected: (and/c number? (between/c 0 1))*
> *  given: 3*
> *  which isn't: (between/c 0 1)*
> *  in: the 1st argument of*
> *  the range of*
> *  (->*
> *   bezier-control-point?*
> *   bezier-control-point?*
> *   (->**
> *((and/c number? (between/c 0 1)))*
> *(#:clamp-range boolean?)*
> *number?))*
> *  contract from: *
> *  /home/alexander/Workspace/Racket/cubic-bezier.rkt*
> *  blaming: /home/alexander/Workspace/Racket/experimental.rkt*
> *  at: /home/alexander/Workspace/Racket/cubic-bezier.rkt:8.11*
>
>
> 
>
> Is there a way I can fine-tune the error message so instead of saying
>
> * in: the 1st argument of*
> *  the range of*
> *  (->*
> *   bezier-control-point?*
> *   bezier-control-point?*
> *   (->**
> *((and/c number? (between/c 0 1)))*
> *(#:clamp-range boolean?)*
> *number?))*
>
> It says
>
> * in: the 1st argument of*
> *  the range of*
> *   (->**
> *((and/c number? (between/c 0 1)))*
> *(#:clamp-range boolean?)*
> *number?)*
>
> The above contract is really what is coming into play here when using
> curve, the surrounding -> form is a distraction and I stare at it for a few
> moments mentally parsing to find the right part that is being violated. The
> -> contract is only relevant to cubic-bezier and I think confusing because
> the lambda that is returned from cubic-bezier may be called after some time
> has passed and — at least for me — cubic-bezier is long since gone, and
> thus out of mind.
>
> Alexander McLin
>
>
>
> On Fri, Oct 3, 2014 at 9:59 PM, Alexander McLin 
> wrote:
>
>> Good evening Mathias,
>>
>> After studying your program and mine, and running various permutations, I
>> understand where I was going wrong. It appears that while doing manual
>> experimentation I had gotten confused to which module I was actually in the
>> REPL when calling various functions by hand. Also my test cases weren't
>> fine grained enough to detect each unique contract violation generated by
>> suitable bad inputs.
>>
>> Thanks Mathias! Your examples have helped to sharpen my understanding of
>> how contract boundaries work.
>>
>> Alex
>>
>> On Thu, Oct 2, 2014 at 2:36 PM, Matthias Felleisen 
>> wrote:
>>
>>>
>>> If you use this as the program:
>>>
>>> #lang racket
>>>
>>> ;; contracts set up boundaries between two regions of a program, say two
>>> modules
>>>
>>> ;;
>>> ---
>>> ;; the library
>>> (provide (contract-out
>>>[struct bezier-control-point ((x (and/c number? (between/c 0
>>> 1))) (y number?))]
>>>[cubic-bezier (-> bezier-control-point?
>>>  bezier-control-point?
>>>  (->* ((and/c number? (between/c 0 1)))
>>>   (#:clamp-range boolean?)
>>>   number?))]))
>>>
>>> (struct bezier-control-point (x y) #:transparent)
>>>
>>> (define (cubic-bezier a b)
>>>   ;; now produce a curve via Bezier triangulation
>>>   (lambda (x #:clamp-range [cr #f])
>>> x))
>>>
>>> ;;
>>> ---
>>> ;; the module that uses it
>>> (module+ test
>>>  (require (submod ".."))
>>>
>>>  (define a (bezier-control-point 0.1 5.0))
>>>  (define b (bezier-control-point 0.3 9.0))
>>>
>>>  ((cubic-bezier a b)

Re: [racket] Understanding contracts

2014-10-03 Thread Alexander McLin
Actually I wasn't quite ready to move on.

When I apply (curve 3) where (define curve (cubic-bezier a b) a and b are
bezier-control-point?

I get the following contract error:

---
*(curve 3)*
*. . cubic-bezier: contract violation*
*  expected: (and/c number? (between/c 0 1))*
*  given: 3*
*  which isn't: (between/c 0 1)*
*  in: the 1st argument of*
*  the range of*
*  (->*
*   bezier-control-point?*
*   bezier-control-point?*
*   (->**
*((and/c number? (between/c 0 1)))*
*(#:clamp-range boolean?)*
*number?))*
*  contract from: *
*  /home/alexander/Workspace/Racket/cubic-bezier.rkt*
*  blaming: /home/alexander/Workspace/Racket/experimental.rkt*
*  at: /home/alexander/Workspace/Racket/cubic-bezier.rkt:8.11*



Is there a way I can fine-tune the error message so instead of saying

* in: the 1st argument of*
*  the range of*
*  (->*
*   bezier-control-point?*
*   bezier-control-point?*
*   (->**
*((and/c number? (between/c 0 1)))*
*(#:clamp-range boolean?)*
*number?))*

It says

* in: the 1st argument of*
*  the range of*
*   (->**
*((and/c number? (between/c 0 1)))*
*(#:clamp-range boolean?)*
*number?)*

The above contract is really what is coming into play here when using
curve, the surrounding -> form is a distraction and I stare at it for a few
moments mentally parsing to find the right part that is being violated. The
-> contract is only relevant to cubic-bezier and I think confusing because
the lambda that is returned from cubic-bezier may be called after some time
has passed and — at least for me — cubic-bezier is long since gone, and
thus out of mind.

Alexander McLin



On Fri, Oct 3, 2014 at 9:59 PM, Alexander McLin 
wrote:

> Good evening Mathias,
>
> After studying your program and mine, and running various permutations, I
> understand where I was going wrong. It appears that while doing manual
> experimentation I had gotten confused to which module I was actually in the
> REPL when calling various functions by hand. Also my test cases weren't
> fine grained enough to detect each unique contract violation generated by
> suitable bad inputs.
>
> Thanks Mathias! Your examples have helped to sharpen my understanding of
> how contract boundaries work.
>
> Alex
>
> On Thu, Oct 2, 2014 at 2:36 PM, Matthias Felleisen 
> wrote:
>
>>
>> If you use this as the program:
>>
>> #lang racket
>>
>> ;; contracts set up boundaries between two regions of a program, say two
>> modules
>>
>> ;;
>> ---
>> ;; the library
>> (provide (contract-out
>>[struct bezier-control-point ((x (and/c number? (between/c 0
>> 1))) (y number?))]
>>[cubic-bezier (-> bezier-control-point?
>>  bezier-control-point?
>>  (->* ((and/c number? (between/c 0 1)))
>>   (#:clamp-range boolean?)
>>   number?))]))
>>
>> (struct bezier-control-point (x y) #:transparent)
>>
>> (define (cubic-bezier a b)
>>   ;; now produce a curve via Bezier triangulation
>>   (lambda (x #:clamp-range [cr #f])
>> x))
>>
>> ;;
>> ---
>> ;; the module that uses it
>> (module+ test
>>  (require (submod ".."))
>>
>>  (define a (bezier-control-point 0.1 5.0))
>>  (define b (bezier-control-point 0.3 9.0))
>>
>>  ((cubic-bezier a b)
>>   ;; a contract violation because i isn't comparable
>>   (sqrt -1)))
>>
>>
>> drracket or raco test file.rkt will show contract errors.
>>
>>
>>
>>
>> On Oct 2, 2014, at 1:50 PM, Alexander McLin  wrote:
>>
>> > Spencer, I'm calling cubic-bezier from within a (module+ test (require
>> submod "..")...) form that itself is defined in the file where cubic-bezier
>> is defined. Also I tried from within REPL and requiring the code file.
>> >
>> > Matthias,
>> >
>> > I ran your example and it works exactly the way I wanted. The lambda
>> returned from cubic-bezier properly raises contract violations when bad
>> inputs are given for the required parameter and optional keyword.
>> >
>> > Examining the differences between your example and my original
>>

Re: [racket] Understanding contracts

2014-10-03 Thread Alexander McLin
Good evening Mathias,

After studying your program and mine, and running various permutations, I
understand where I was going wrong. It appears that while doing manual
experimentation I had gotten confused to which module I was actually in the
REPL when calling various functions by hand. Also my test cases weren't
fine grained enough to detect each unique contract violation generated by
suitable bad inputs.

Thanks Mathias! Your examples have helped to sharpen my understanding of
how contract boundaries work.

Alex

On Thu, Oct 2, 2014 at 2:36 PM, Matthias Felleisen 
wrote:

>
> If you use this as the program:
>
> #lang racket
>
> ;; contracts set up boundaries between two regions of a program, say two
> modules
>
> ;;
> ---
> ;; the library
> (provide (contract-out
>[struct bezier-control-point ((x (and/c number? (between/c 0
> 1))) (y number?))]
>[cubic-bezier (-> bezier-control-point?
>  bezier-control-point?
>  (->* ((and/c number? (between/c 0 1)))
>   (#:clamp-range boolean?)
>   number?))]))
>
> (struct bezier-control-point (x y) #:transparent)
>
> (define (cubic-bezier a b)
>   ;; now produce a curve via Bezier triangulation
>   (lambda (x #:clamp-range [cr #f])
> x))
>
> ;;
> ---
> ;; the module that uses it
> (module+ test
>  (require (submod ".."))
>
>  (define a (bezier-control-point 0.1 5.0))
>  (define b (bezier-control-point 0.3 9.0))
>
>  ((cubic-bezier a b)
>   ;; a contract violation because i isn't comparable
>   (sqrt -1)))
>
>
> drracket or raco test file.rkt will show contract errors.
>
>
>
>
> On Oct 2, 2014, at 1:50 PM, Alexander McLin  wrote:
>
> > Spencer, I'm calling cubic-bezier from within a (module+ test (require
> submod "..")...) form that itself is defined in the file where cubic-bezier
> is defined. Also I tried from within REPL and requiring the code file.
> >
> > Matthias,
> >
> > I ran your example and it works exactly the way I wanted. The lambda
> returned from cubic-bezier properly raises contract violations when bad
> inputs are given for the required parameter and optional keyword.
> >
> > Examining the differences between your example and my original
> implementation, my functions are directly defined in top level in the file,
> after #lang racket, not wrapped within a module. And I'm running my test
> cases within a (module+ test (require submod "..")) form.
> >
> > In my test cases within (module+ test...), violations are correctly
> reported when I give bad inputs to cubic-bezier and bezier-control-point
> structs. Except the lambda, no violations are reported with bad inputs. Is
> it because I'm incorrectly using modules? I had thought that module+ and
> (require submod "..") would allow the contract system to come into full
> force.
> >
> >
> >
> > On Thu, Oct 2, 2014 at 9:20 AM, Matthias Felleisen 
> wrote:
> >
> > Let's make Spencer's question concrete. Say we have this situation:
> >
> > #lang racket
> >
> > ;; contracts set up boundaries between two regions of a program, say two
> modules
> >
> > ;;
> ---
> > ;; the library
> > (module server racket
> >   (provide (contract-out
> > [struct bezier-control-point ((x (and/c number? (between/c 0
> 1))) (y number?))]
> > [cubic-bezier (-> bezier-control-point?
> >   bezier-control-point?
> >   (->* ((and/c number? (between/c 0 1)))
> >(#:clamp-range boolean?)
> >number?))]))
> >
> >   (struct bezier-control-point (x y) #:transparent)
> >
> >   (define (cubic-bezier a b)
> > ;; now produce a curve via Bezier triangulation
> > (lambda (x #:clamp-range [cr #f])
> >   x)))
> >
> > ;;
> ---
> > ;; the module that uses it
> > (module client racket
> >   (require (submod ".." server))
> >
> >   (define a (bezier-control-point 0.1 5.0))
> >   (define b (bezier-control-point 0.3 9

Re: [racket] Understanding contracts

2014-10-02 Thread Alexander McLin
Spencer, I'm calling cubic-bezier from within a (module+ test (require
submod "..")...) form that itself is defined in the file where cubic-bezier
is defined. Also I tried from within REPL and requiring the code file.

Matthias,

I ran your example and it works exactly the way I wanted. The lambda
returned from cubic-bezier properly raises contract violations when bad
inputs are given for the required parameter and optional keyword.

Examining the differences between your example and my original
implementation, my functions are directly defined in top level in the file,
after #lang racket, not wrapped within a module. And I'm running my test
cases within a (module+ test (require submod "..")) form.

In my test cases within (module+ test...), violations are correctly
reported when I give bad inputs to cubic-bezier and bezier-control-point
structs. Except the lambda, no violations are reported with bad inputs. Is
it because I'm incorrectly using modules? I had thought that module+ and
(require submod "..") would allow the contract system to come into full
force.



On Thu, Oct 2, 2014 at 9:20 AM, Matthias Felleisen 
wrote:

>
> Let's make Spencer's question concrete. Say we have this situation:
>
> #lang racket
>
> ;; contracts set up boundaries between two regions of a program, say two
> modules
>
> ;;
> ---
> ;; the library
> (module server racket
>   (provide (contract-out
> [struct bezier-control-point ((x (and/c number? (between/c 0
> 1))) (y number?))]
> [cubic-bezier (-> bezier-control-point?
>   bezier-control-point?
>   (->* ((and/c number? (between/c 0 1)))
>(#:clamp-range boolean?)
>number?))]))
>
>   (struct bezier-control-point (x y) #:transparent)
>
>   (define (cubic-bezier a b)
> ;; now produce a curve via Bezier triangulation
> (lambda (x #:clamp-range [cr #f])
>   x)))
>
> ;;
> ---
> ;; the module that uses it
> (module client racket
>   (require (submod ".." server))
>
>   (define a (bezier-control-point 0.1 5.0))
>   (define b (bezier-control-point 0.3 9.0))
>
>   ((cubic-bezier a b)
>;; a contract violation because i isn't comparable
>(sqrt -1)))
>
> ;;
> ---
> ;; run program run
> (require 'client)
>
> I assume you want to see other violations. Can you explain with this
> example w/o going into Bezier?
> (I just know enough about Bezier to draw curves.)
>
> -- Matthias
>
>
>
>
> On Oct 1, 2014, at 10:46 PM, Alexander McLin  wrote:
>
> > Hello,
> >
> > I've been working on a sample project to better understand how to use
> the contract system. I created a simple Bezier curve implementation and am
> using (provide (contract-out...) to attach contracts to the provided
> bindings.
> >
> > Basically I have a procedure called cubic-bezier that accepts two
> control point structs used to define the curve. It returns another
> procedure that actually generates the curve, it accepts an integer
> parameter that lies on [0, 1] and an optional keyword #:clamp-range. The
> generator procedure returns a number.
> >
> > The control point structure is a simple posn type that accepts X and Y
> fields where X must be between 0 and 1, and Y is allowed to be any number.
> >
> > Here are the contracts I defined provisionally:
> >
> > (provide (contract-out
> >   [struct bezier-control-point ((x (and/c number? (between/c 0
> 1)))
> >   (y number?))]
> >   [cubic-bezier (-> bezier-control-point?
> >  bezier-control-point?
> > (->* ((and/c number? (between/c 0
> 1)))
> >(#:clamp-range boolean?)
> >number?))]))
> >
> > For the contract attached to cubic-bezier using ->, my thinking was to
> use ->* to generate the contract for the procedure returned by cubic-bezier
> but it's not working, meaning I'm not getting the any contract violations
> I'm expecting when giving bad inputs to cubic-bezier's value.
> >
> > How can I attach a more complex contract to cubic-bezier's value?
> >
> > Thank you
> > Alexander McLin
> > 
> >  Racket Users list:
> >  http://lists.racket-lang.org/users
>
>

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


[racket] Understanding contracts

2014-10-01 Thread Alexander McLin
Hello,

I've been working on a sample project to better understand how to use the
contract system. I created a simple Bezier curve implementation and am
using (provide (contract-out...) to attach contracts to the provided
bindings.

Basically I have a procedure called cubic-bezier that accepts two control
point structs used to define the curve. It returns another procedure that
actually generates the curve, it accepts an integer parameter that lies on
[0, 1] and an optional keyword #:clamp-range. The generator procedure
returns a number.

The control point structure is a simple posn type that accepts X and Y
fields where X must be between 0 and 1, and Y is allowed to be any number.

Here are the contracts I defined provisionally:

(provide (contract-out
  [struct bezier-control-point ((x (and/c number? (between/c 0 1)))
  (y number?))]
  [cubic-bezier (-> bezier-control-point?
 bezier-control-point?
(->* ((and/c number? (between/c 0 1)))
   (#:clamp-range boolean?)
   number?))]))

For the contract attached to cubic-bezier using ->, my thinking was to use
->* to generate the contract for the procedure returned by cubic-bezier but
it's not working, meaning I'm not getting the any contract violations I'm
expecting when giving bad inputs to cubic-bezier's value.

How can I attach a more complex contract to cubic-bezier's value?

Thank you
Alexander McLin

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


Re: [racket] users Digest, Vol 109, Issue 55

2014-09-29 Thread Alexander McLin
Good grief, was it necessary to spam the list with your requests? You could
have just sent one email instead of replying to like 20 different threads?

And it would have been nice if you'd read the basic instructions which
tells you exactly how to unsubscribe yourself without flooding my inbox.

On Mon, Sep 29, 2014 at 4:44 PM, Moshe Deutsch 
wrote:

> Please take me off the list
>
> Thanks
>
> On Thu, Sep 25, 2014 at 8:57 AM,   wrote:
> > Send users mailing list submissions to
> > users@racket-lang.org
> >
> > To subscribe or unsubscribe via the World Wide Web, visit
> > http://lists.racket-lang.org/users/listinfo
> > or, via email, send a message with subject or body 'help' to
> > users-requ...@racket-lang.org
> >
> > You can reach the person managing the list at
> > users-ow...@racket-lang.org
> >
> > When replying, please edit your Subject line so it is more specific
> > than "Re: Contents of users digest..."
> >
> >
> > [Racket Users list:
> >  http://lists.racket-lang.org/users ]
> >
> >
> > Today's Topics:
> >
> >1. macro question (Alejandro Zamora)
> >2. Re: ranking items by their appearance in sets (David T. Pierson)
> >3. Switching from editor to repl (C K Kashyap)
> >4. Re: Switching from editor to repl (Jay McCarthy)
> >5. Re: Switching from editor to repl (C K Kashyap)
> >6. Re: Switching from editor to repl (Robby Findler)
> >
> >
> > --
> >
> > Message: 1
> > Date: Wed, 24 Sep 2014 22:35:49 -0400
> > From: Alejandro Zamora 
> > To: Racket Users 
> > Subject: [racket] macro question
> > Message-ID: <20140924223549.7f15c912@alejandro-H61H2-CM>
> > Content-Type: text/plain; charset=US-ASCII
> >
> > Hi Racket people:
> > I have a (maybe too simple) question:
> > How I create one macro like this (but using define-macro &
> > R5RS language only)?:
> >
> > (vars sym var-cant val-of-vars)
> >
> > Example:
> > (vars id 5 null) -> (prog (define id1 null)
> >   (define id2 null)
> >   (define id3 null)
> >   (define id4 null)
> >   (define id5 null))
> >
> > --
> > Nunca digas nunca, di mejor: gracias, permiso, disculpe.
> >
> > Este mensaje le ha llegado mediante el servicio de correo electronico
> que ofrece Infomed para respaldar el cumplimiento de las misiones del
> Sistema Nacional de Salud. La persona que envia este correo asume el
> compromiso de usar el servicio a tales fines y cumplir con las regulaciones
> establecidas
> >
> > Infomed: http://www.sld.cu/
> >
> >
> >
> > --
> >
> > Message: 2
> > Date: Wed, 24 Sep 2014 23:07:13 -0400
> > From: "David T. Pierson" 
> > To: Matthias Felleisen 
> > Cc: users@racket-lang.org
> > Subject: Re: [racket] ranking items by their appearance in sets
> > Message-ID: <1411613699.19584%...@mindstory.com>
> > Content-Type: text/plain; charset=us-ascii
> >
> > On Wed, Sep 24, 2014 at 10:44:45AM -0400, Matthias Felleisen wrote:
> >> Style: Here is my rewrite with style suggestions. I liked to have a
> >> single point that tests all versions of a function when I conduct such
> >> design experiments. I also want to have all my test code in the test
> >> submodule so that it doesn't get deployed. That's why I am using a
> >> syntactic abstraction that unfolds into a submodule rather than a
> >> function that calls things.
> >
> > Thanks for the style suggestions.  I am reminded I need to reread the
> > style guide.
> >
> >> Performance: I have not checked their performance but I cannot imagine
> >> the first version to be performant. See my annotations.
> >
> > Good point.  I had put performance out of my mind because my real data
> > is relatively small and I just wanted to play a bit with the methods,
> > but I definitely appreciate the notes.
> >
> >> My choice: Your second version is what I would have written.
> >
> > Glad to know I was on the right track.
> >
> > Thank you.
> >
> > David
> >
> >
> > --
> >
> > Message: 3
> > Date: Thu, 25 Sep 2014 11:47:57 +0530
> > From: C K Kashyap 
> > To: users@racket-lang.org
> > Subject: [racket] Switching from editor to repl
> > Message-ID:
> > <
> cagdt1gqup-0hdf15fyo2t_qpm+qf9akkmak_ilv9htc4wkd...@mail.gmail.com>
> > Content-Type: text/plain; charset="utf-8"
> >
> > Hi,
> > I am new to racket (but am really excited by the idea - everything is a
> > program) - need a quick help with Dr Racket -
> >
> > What's the keyboard shortcut to switch between editor and repl?
> >
> > I got to know from a video on youtube that I could use C-e to toggle the
> > repl visibility but not able to find out how to get to the rpl using the
> > keyboard.
> > Regards,
> > Kashyap
> > -- next part --
> > An HTML attachment was scrubbed...
> > URL: <
> http://li

Re: [racket] contracts ->i optional keyword syntax

2014-08-26 Thread Alexander McLin
Thank you for this information. I had been trying to figure out how to test 
contracts from within a module+ only to give up and move my test cases to a 
different file.

I think this reinforces that I should be asking more questions on the mailing 
list.

Alexander McLin



> On Aug 26, 2014, at 5:53 PM, Matthias Felleisen  wrote:
> 
> 
>> On Aug 26, 2014, at 5:43 PM, Kevin Forchione  wrote:
>> 
>> 
>>> On Aug 24, 2014, at 2:09 PM, Matthias Felleisen  
>>> wrote:
>>> 
>>> Before you make fondue, ask. As you can see, people answer and answer 
>>> quickly. Indeed, Robby added an example to the Guide as he responded and 
>>> pushed it out into the repo. The next release will have an example due to 
>>> your posts. Thanks! 
>>> 
>>> Having said that, Racket is created by people who focus on systematic 
>>> design of software. The contract system is an example of this; 
>>> 
>>> -- it serves the purpose of creating software systematically (continuing 
>>> the so-called Design by Contract line of work) 
>>> -- it itself is developed systematically with inquires into the semantics 
>>> of contracts because we took contracts way beyond the primitive notion from 
>>> the 1980s and 1990s. 
>>> 
>>> But, the existence of ->i and ->d should give you a hint that we 
>>> occasionally make mistakes and we try to correct them without modifying 
>>> existing code. ->d is mostly okay, but ->i is better. When Robby created 
>>> ->i, he also used his experience with ->d to force programmers to list 
>>> dependency variables explicitly. That's why you have to say "(lst)", for 
>>> example. In addition, the language grows and with it, we have to grow the 
>>> contract system. Keyword arguments is an example of that kind. 
>>> 
>>> As for the philosophy behind our contract system, I think the guide's 
>>> opening section on boundaries brings across the idea that separates our 
>>> contracts from old-style stuff. It may not become immediately clear, but 
>>> when you program with contracts for a while, you will appreciate it.
>> 
>> Wow! I am increasingly appreciating this approach (along with Racket’s 
>> systematic approach to design). 
>> 
>> I’m slowly converting my modules over to use contract-out and the ->i form 
>> makes it easy to see at a glance what the domains and ranges are, and I’m 
>> thinking the notation might be useful in the function definition’s comments 
>> as well. Is there a way to integrate unit testing into this approach? The 
>> (module+ test …) unit testing I’ve been doing is within the boundary of the 
>> mode and I wonder if there isn’t a way to simply move those test cases into 
>> another module (within the same file) and require it into the (module+ test 
>> …) form?
> 
> 
> Yes, you can use submodules to import the outer module thru the contract 
> boundary and then run unit tests in the submodule: 
> 
> 
> #lang racket
> 
> (provide 
> (contract-out
>  (f (-> integer? integer?
> 
> ;; -
> ;; implementation 
> 
> (module+ test (require rackunit))
> 
> (define (f x)
>  x)
> 
> (module+ test 
>  (require (submod ".."))
>  (check-equal? (f 1) 1)
>  (check-equal? (f 'a) 'a))
> 
> 
> We should probably document this little trick somewhere. -- Matthias
> 
> 
> 
>  Racket Users list:
>  http://lists.racket-lang.org/users


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


Re: [racket] Announce: multiplayer networked coop game in racket

2014-07-12 Thread Alexander McLin
This is fun! I loved how my screen would shake and flicker each time I get
slammed by a fire volley. Certainly got my adrenaline pumping.


On Sat, Jul 12, 2014 at 12:01 PM, David Vanderson  wrote:

> For the past 6 months my hobby has been writing the beginnings of a
> lan-party game in Racket:
>
> https://github.com/david-vanderson/warp
>
> It's good enough now to provide 10-15 minutes of fun.  I've attached a
> screenshot.  Please try it out and let me know what you think!
>
> The README.md has instructions, but briefly:
> - download the source from github
> - start one server
>$ racket sandbox.rkt
> - start each client
>$ racket client.rkt
> Type your name, the IP address of the server, and start clicking. The game
> only uses mouse clicks, no keyboard.  The gray boxes with text on them are
> buttons.  Try launching a ship off of the rebel base and flying towards the
> enemy base (off to the right).
>
> Thanks to Vincent for pushing me to announce it, Ryan for encouraging me
> to start it, and Matthew for patiently dealing with my GUI questions.  At
> this year's RacketCon I'll give a short talk about writing it.  And a huge
> thank you to all the Racket developers for making an incredible platform!
>
> Thanks,
> Dave
>
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
>

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


Re: [racket] Q. about 'nostops' in MTWT paper

2014-05-09 Thread Alexander McLin
Thanks!


On Fri, May 9, 2014 at 11:33 AM, David Van Horn  wrote:

> On 5/9/14, 11:29 AM, Alexander McLin wrote:
> > Do you mind expanding on what MTWT stands for? I'm not familiar with this
> > paper and am curious.
>
> Macros that Work Together
> http://www.eecs.northwestern.edu/~robby/pubs/papers/jfp2012-fcdf.pdf
>
>
> > On Thu, May 8, 2014 at 6:20 PM, John Clements  >wrote:
> >
> >>
> >> On May 8, 2014, at 3:00 PM, Ryan Culpepper  wrote:
> >>
> >>> IIRC, the typesetting of environment extension might suggest
> replacement
> >> in a mapping, but I believe it actually means 'cons' in an association
> >> list, and 'nostops' is one thing that relies on the latter
> implementation
> >> of the environment rather than the former.
> >>
> >> Ah… so the model does in fact have the “uncovering” behavior I expected
> it
> >> to.  In this case, I think that the text of the paper is mistaken; it
> says
> >>
> >> nostops[xi] = {var -> transform | xi(var) = transform and transform !=
> >> STOP }
> >>
> >> which certainly suggests to me that these mappings simply wouldn’t
> appear
> >> in the updated mapping.
> >>
> >> Amazing how ambiguous formal syntax can be.
> >>
> >> It seems like the right way to fix this would be to explicitly separate
> >> the environment xi into a mapping and a stop list—the ‘nostops’
> definition
> >> would be trivial, but lookup in xi would get slightly uglier. Perhaps a
> >> footnote somewhere in the paper?
> >>
> >> Anyway, thanks for clarifying.
> >>
> >>
> >>
> >> John
> >>
> >>>
> >>> So an environment with 'lambda' in the stop list actually looks like
> >>>
> >>>  ((lambda STOP) (lambda FUN))
> >>>
> >>> so when 'nostops' filters it, it produces
> >>>
> >>>  ((lambda FUN))
> >>>
> >>> and the previous meaning of 'lambda' is restored.
> >>>
> >>> Ryan
> >>>
> >>>
> >>> On 05/08/2014 04:58 PM, John Clements wrote:
> >>>> I’m reading through MTWT for the nth time, and this time I have a
> >> question about the ‘nostops’ metafunction, part of local expansion.
> >>>>
> >>>> Specifically: ‘nostops’ takes an environment xi, and strips out
> >> everything bound to 'STOP’. This prevents the ’STOP’s from an enclosing
> >> local expand from being in force in this one.  However, it seems to me
> that
> >> the ’nostops’ metafunction should restore the bindings that were in
> place
> >> before they were mapped to STOP. More specifically; suppose a
> local-expand
> >> specifies, say, ‘lambda’ as a STOP. This replaces the mapping from
> ‘lambda’
> >> to FUN with a mapping from ‘lambda’ to ’STOP’. Then, a nested
> local-expand
> >> uses a different stop-list, that doesn’t include ‘lambda’. If I’m
> reading
> >> the paper correctly, this local expansion would then take place in a
> ‘xi’
> >> where there was no binding for lambda at *all*, which would presumably
> lead
> >> to an error during that expansion.
> >>>>
> >>>> I checked out the model, to see if this was a typesetting issue, but
> it
> >> seems pretty clear to me that the model linked to by the paper has
> exactly
> >> this property; it’s simply filtering the ‘xi’ environment to throw out
> >> things that were bound to STOP.
> >>>>
> >>>> I tried to construct a racket program to illustrate my question, and
> >> here’s what I came up with:
> >>>>
> >>>> #lang racket
> >>>>
> >>>> (let-syntax ([boring (lambda (stx) (cadr (syntax->list stx)))])
> >>>>
> >>>>   (let-syntax ([a (lambda (stx)
> >>>> (local-expand (cadr (syntax->list stx))
> >>>>   'expression
> >>>>   (list #'boring)))])
> >>>> (let-syntax ([b (lambda (stx)
> >>>>   (local-expand (cadr (syntax->list stx))
> >>>> 'expression
> >>>> (list)))])
> >>>>   (a (b (boring 34))
> >>>>
> >>>> Unsurprisingly, this evaluated to the “correct” value, 34.  This means
> >> that either the model doesn’t match Racket, or (more likely) I’m
> >> misunderstanding the model. Or possibl
> >>>>
> >>>> Ah, what the heck; I’ll cc: the whole racket list. I’ll take help
> >> wherever I can get it :).
> >>>>
> >>>> John
> >>>>
> >>>
> >>
> >>
> >> 
> >>   Racket Users list:
> >>   http://lists.racket-lang.org/users
> >>
> >
> >
> >
> > 
> >   Racket Users list:
> >   http://lists.racket-lang.org/users
> >
>
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users
>

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


Re: [racket] Q. about 'nostops' in MTWT paper

2014-05-09 Thread Alexander McLin
Do you mind expanding on what MTWT stands for? I'm not familiar with this
paper and am curious.


On Thu, May 8, 2014 at 6:20 PM, John Clements wrote:

>
> On May 8, 2014, at 3:00 PM, Ryan Culpepper  wrote:
>
> > IIRC, the typesetting of environment extension might suggest replacement
> in a mapping, but I believe it actually means 'cons' in an association
> list, and 'nostops' is one thing that relies on the latter implementation
> of the environment rather than the former.
>
> Ah… so the model does in fact have the “uncovering” behavior I expected it
> to.  In this case, I think that the text of the paper is mistaken; it says
>
> nostops[xi] = {var -> transform | xi(var) = transform and transform !=
> STOP }
>
> which certainly suggests to me that these mappings simply wouldn’t appear
> in the updated mapping.
>
> Amazing how ambiguous formal syntax can be.
>
> It seems like the right way to fix this would be to explicitly separate
> the environment xi into a mapping and a stop list—the ‘nostops’ definition
> would be trivial, but lookup in xi would get slightly uglier. Perhaps a
> footnote somewhere in the paper?
>
> Anyway, thanks for clarifying.
>
>
>
> John
>
> >
> > So an environment with 'lambda' in the stop list actually looks like
> >
> >  ((lambda STOP) (lambda FUN))
> >
> > so when 'nostops' filters it, it produces
> >
> >  ((lambda FUN))
> >
> > and the previous meaning of 'lambda' is restored.
> >
> > Ryan
> >
> >
> > On 05/08/2014 04:58 PM, John Clements wrote:
> >> I’m reading through MTWT for the nth time, and this time I have a
> question about the ‘nostops’ metafunction, part of local expansion.
> >>
> >> Specifically: ‘nostops’ takes an environment xi, and strips out
> everything bound to 'STOP’. This prevents the ’STOP’s from an enclosing
> local expand from being in force in this one.  However, it seems to me that
> the ’nostops’ metafunction should restore the bindings that were in place
> before they were mapped to STOP. More specifically; suppose a local-expand
> specifies, say, ‘lambda’ as a STOP. This replaces the mapping from ‘lambda’
> to FUN with a mapping from ‘lambda’ to ’STOP’. Then, a nested local-expand
> uses a different stop-list, that doesn’t include ‘lambda’. If I’m reading
> the paper correctly, this local expansion would then take place in a ‘xi’
> where there was no binding for lambda at *all*, which would presumably lead
> to an error during that expansion.
> >>
> >> I checked out the model, to see if this was a typesetting issue, but it
> seems pretty clear to me that the model linked to by the paper has exactly
> this property; it’s simply filtering the ‘xi’ environment to throw out
> things that were bound to STOP.
> >>
> >> I tried to construct a racket program to illustrate my question, and
> here’s what I came up with:
> >>
> >> #lang racket
> >>
> >> (let-syntax ([boring (lambda (stx) (cadr (syntax->list stx)))])
> >>
> >>   (let-syntax ([a (lambda (stx)
> >> (local-expand (cadr (syntax->list stx))
> >>   'expression
> >>   (list #'boring)))])
> >> (let-syntax ([b (lambda (stx)
> >>   (local-expand (cadr (syntax->list stx))
> >> 'expression
> >> (list)))])
> >>   (a (b (boring 34))
> >>
> >> Unsurprisingly, this evaluated to the “correct” value, 34.  This means
> that either the model doesn’t match Racket, or (more likely) I’m
> misunderstanding the model. Or possibl
> >>
> >> Ah, what the heck; I’ll cc: the whole racket list. I’ll take help
> wherever I can get it :).
> >>
> >> John
> >>
> >
>
>
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users
>

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


Re: [racket] package server + making docs available early

2014-05-02 Thread Alexander McLin
Looking forward to checking out your Pollen package in more detail, just
wanted to add that after reading your original email and following the
links, I eventually discovered myself losing a hour or two reading your
typographical book. Very nicely written and I look forward to studying it
more carefully for my writings.

Alex


On Fri, May 2, 2014 at 11:37 AM, Laurent  wrote:

> On Fri, May 2, 2014 at 5:06 PM, Greg Hendershott <
> greghendersh...@gmail.com> wrote:
>
>> For smaller/simpler libraries I find futzing with gh-pages enough of a
>> PITA that instead I just do:
>>
>> scribble --markdown manual.scrbl
>>
>> The resulting manual.md file is directly viewable on GitHub on a
>> normal branch like master. Example:
>> https://github.com/greghendershott/http/blob/master/http/manual.md
>>
>>
> I completely second this approach. Very simple for a front README.md, but
> with most of the power of scribble.
> One thing that could need improvement IMHO is the verbatim output of
> several lines, which would be better with a block than with successive
> single lines of verbatim, as can be seen in the License section at the
> bottom of the above link. (I had look a little into this issue, but gave up
> early.)
>
> Laurent
>
>
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
>

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


Re: [racket] first vs car ; last vs cdr ; empty? vs null?

2014-03-08 Thread Alexander McLin
I see, thanks for the detailed explanation. I understand the issue is whether 
the cost associated with cons checking arguments prior to creating the pair is 
acceptable or not but truly if cons is checking for list? by whether a bit is 
set or not, wouldn't that be negligible compared to the cost of creating the 
pair in the first place?

Now I'm curious enough to want to try modifying cons on my own and seeing what 
happens. Do you mind giving me pointers on how to do that? I imagine it'd 
require changing the source code and compiling racket?

> On Mar 8, 2014, at 1:00 PM, Matthew Flatt  wrote:
> 
> I've never measured carefully enough to be sure that it's better to put
> the cost in `list?` instead of `cons`, but my guess is that the cost is
> better in `list?`.
> 
> There's an `unsafe-cons-list` function sets the is-a-list bit when
> creating a pair. That is, it always sets the bit without a test on the
> second argument.
> 
> Some function, such as `list`, internally use `unsafe-cons-list`, since
> the pairs that the function creates always form a list. In some limited
> cases, the compiler effectively replaces `cons` with `unsafe-cons-list`
> to set the bit early where no run-time test is needed. Currently,
> `make-list` does not use `unsafe-cons-list` and the compiler is not
> smart enough to replace its `cons` with `unsafe-cons-list`.
> 
> At Sat, 8 Mar 2014 12:53:06 -0500, Matthias Felleisen wrote:
>> 
>> I sit corrected :-) (I had it right at some point)
>> 
>> 
>>> On Mar 8, 2014, at 12:52 PM, Carl Eastlund wrote:
>>> 
>>> If every cons set those bits, it would still take constant time because
>> you'd only have to look one deep.  However, the important part is that 
>> currently cons never has to inspect its arguments.  Given that cons may be 
>> called frequently in a program that never uses list?, one does not want to 
>> pay 
>> for inspecting those arguments until needed.
>>> 
>>> Carl Eastlund
>>> 
>>> 
 On Sat, Mar 8, 2014 at 12:47 PM, Matthias Felleisen 
>>> wrote:
>>> 
>>> You want cons (the frequent action) to take constant time: allocate pointer,
>> set two fields.
>>> 
>>> 
 On Mar 8, 2014, at 12:33 PM, David T. Pierson wrote:
 
> On Fri, Mar 07, 2014 at 11:03:57PM -0500, Carl Eastlund wrote:
> The first/rest operations do not use a memoization table.  They test using
> the list? primitive, which is built in and actually has a couple of tag
> bits reserved on every cons object for memoizing its results.  So the
> operation really is quite fast.
 
 I take this to mean there is a bit in the cons object for storing
 whether it is a list, and that this bit is set via `list?'.
 
 Why wouldn't the bit be set via `cons'?
 
 Also, when I do:
 
 $ racket
 Welcome to Racket v6.0.0.2.
> (let ((ls (make-list 5000 0)))
   (time (list? ls))
   (time (list? ls))
   (time (list? ls))
   (time (list? ls))
   (time (list? ls)))
 
 cpu time: 220 real time: 220 gc time: 0
 cpu time: 112 real time: 112 gc time: 0
 cpu time: 60 real time: 58 gc time: 0
 cpu time: 28 real time: 29 gc time: 0
 cpu time: 16 real time: 15 gc time: 0
 #t
 
 Why does the time decrease gradually, rather than the 2nd and subsequent
 times being roughly equivalent?
 
 Thanks.
 
 David
 
 Racket Users list:
 http://lists.racket-lang.org/users
>>> 
>>> 
>>> 
>>>  Racket Users list:
>>>  http://lists.racket-lang.org/users
>> 
>> 
>>  Racket Users list:
>>  http://lists.racket-lang.org/users
> 
>  Racket Users list:
>  http://lists.racket-lang.org/users


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


Re: [racket] first vs car ; last vs cdr ; empty? vs null?

2014-03-08 Thread Alexander McLin
I'm joining in this thread because I'm now wondering about the same questions.

It seems to me that if a list is created via list or make-list then the bits 
should have been set on the car of the new list, so all the list predicates 
have to do is check the first element in O(1) time.

Likewise cons can check to see if the second element is a list and 
correspondingly set bits on the first element.

Thanks to immutable pairs, it seems it should be possible to provide guarantees 
on list? being always O(1) by using the above technique without needing to 
cache results and converging to O(1) in the limit.



> On Mar 8, 2014, at 12:33 PM, "David T. Pierson"  wrote:
> 
>> On Fri, Mar 07, 2014 at 11:03:57PM -0500, Carl Eastlund wrote:
>> The first/rest operations do not use a memoization table.  They test using
>> the list? primitive, which is built in and actually has a couple of tag
>> bits reserved on every cons object for memoizing its results.  So the
>> operation really is quite fast.
> 
> I take this to mean there is a bit in the cons object for storing
> whether it is a list, and that this bit is set via `list?'.
> 
> Why wouldn't the bit be set via `cons'?
> 
> Also, when I do:
> 
>  $ racket
>  Welcome to Racket v6.0.0.2.
>> (let ((ls (make-list 5000 0)))
>(time (list? ls))  
>
>(time (list? ls))  
>
>(time (list? ls))  
>
>(time (list? ls))  
>
>(time (list? ls)))
> 
>  cpu time: 220 real time: 220 gc time: 0
>  cpu time: 112 real time: 112 gc time: 0
>  cpu time: 60 real time: 58 gc time: 0
>  cpu time: 28 real time: 29 gc time: 0
>  cpu time: 16 real time: 15 gc time: 0
>  #t
> 
> Why does the time decrease gradually, rather than the 2nd and subsequent
> times being roughly equivalent?
> 
> Thanks.
> 
> David
> 
>  Racket Users list:
>  http://lists.racket-lang.org/users


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


Re: [racket] About set-car! and set-cdr!

2014-03-05 Thread Alexander McLin
Daniel, I think it'll be worthwhile to direct your attention to this blog
entry which goes into more details about why mutable pairs were removed in
the first place.

http://blog.racket-lang.org/2007/11/getting-rid-of-set-car-and-set-cdr.html


On Wed, Mar 5, 2014 at 4:15 PM, Jens Axel Søgaard wrote:

> (require compatibility/mlist)
> (mlist 1 2 3)
>
> See
> http://docs.racket-lang.org/compatibility/mlists.html?q=mlist#%28def._%28%28lib._compatibility%2Fmlist..rkt%29._mlist%29%29
>
> 2014-03-05 22:06 GMT+01:00 Daniel Carrera :
> >
> > On 5 March 2014 19:54, Matthias Felleisen  wrote:
> >>
> >>
> >> Okay, now see mcons.
> >
> >
> >
> > Neat... mcons, mcar, mcdr, mpair, set-mcar!, set-mcdr!
> >
> > I notice that there is no mlist. Is there a shortcut similar to '(1 2 3)
> to
> > quote a list in a way that makes mutable pairs instead of regular pairs?
> >
> > Cheers,
> > Daniel.
> >
> >
> >>
> >>
> >> On Mar 5, 2014, at 1:53 PM, Daniel Carrera wrote:
> >>
> >> I see.
> >>
> >> k is '(42 2 3) while l is '(1 2 3). This is what I expected to happen,
> but
> >> it is clearly not what was supposed to happen. I just tried the same
> example
> >> with Chicken, and for Chicken both k and l are equal to '(42 2 3).
> >>
> >> Thanks for the explanation.
> >>
> >> Cheers,
> >> Daniel.
> >>
> >> On 5 March 2014 19:24, Matthias Felleisen  wrote:
> >>>
> >>>
> >>> Try
> >>>
> >>>  (define l (list 1 2 3))
> >>>  (define k l)
> >>>
> >>> Now what does (set-car! k 42) do? What should it do?
> >>>
> >>>
> >>> On Mar 5, 2014, at 1:23 PM, Daniel Carrera wrote:
> >>>
> >>> But isn't the final effect the same? The pair may be immutable, but I
> can
> >>> make a new pair and bind it to the old variable. The main difference
> that I
> >>> can see is that what I wrote is a macro, while I believe set-car! is
> >>> supposed to be a function. That could potentially break code.
> >>>
> >>> Cheers,
> >>> Daniel.
> >>>
> >>>
> >>> On 5 March 2014 19:18, Matthias Felleisen 
> wrote:
> 
> 
>  No, set! mutates variable bindings while set-car! mutates cons cells
>  (the first slot of a data structure).
> 
> 
>  On Mar 5, 2014, at 1:13 PM, Daniel Carrera wrote:
> 
>  > Hello,
>  >
>  > My understanding is that Racket intentionally does not provide
>  > set-car! and set-cdr! and that this is one of the ways in which
> Racket is
>  > not fully compatible with Scheme.
>  >
>  > Am I right to think that it is trivially easy to add these features
> to
>  > Racket? Specifically, I'm thinking of:
>  >
>  >
>  > (define-syntax set-car!
>  >   (syntax-rules ()
>  > ((_ l new_car) (set! l (cons new_car (cdr l))
>  >
>  > (define-syntax set-cdr!
>  >   (syntax-rules ()
>  > ((_ l new_cdr) (set! l (cons (car l) new_cdr)
>  >
>  >
>  > Or did I miss something?
>  >
>  > Cheers,
>  > Daniel.
>  > --
>  > When an engineer says that something can't be done, it's a code
> phrase
>  > that means it's not fun to do.
>  > 
>  >  Racket Users list:
>  >  http://lists.racket-lang.org/users
> 
> >>>
> >>>
> >>>
> >>> --
> >>> When an engineer says that something can't be done, it's a code phrase
> >>> that means it's not fun to do.
> >>>
> >>>
> >>
> >>
> >>
> >> --
> >> When an engineer says that something can't be done, it's a code phrase
> >> that means it's not fun to do.
> >>
> >>
> >
> >
> >
> > --
> > When an engineer says that something can't be done, it's a code phrase
> that
> > means it's not fun to do.
> >
> > 
> >   Racket Users list:
> >   http://lists.racket-lang.org/users
> >
>
>
>
> --
> --
> Jens Axel Søgaard
>
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users
>

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


Re: [racket] racket project idea: viable html5 web browser

2014-02-16 Thread Alexander McLin
Unfortunately I don't think I have enough time to be a serious contributing
developer here, but the goals of this project brought to mind another
project I had studied some time ago with similar goals of creating a secure
browser based on a capability-based security model.

The project team used a language - E - implemented on JVM, though I see
they also have a Common Lisp implementation. The capability-based E
language was used to create a browser as part of the DarpaBrowser
initiative a while ago. They also expanded on their browser work to create
a secure desktop environment.

Relevant links: http://www.combex.com/index.html
  http://www.erights.org/#quickstart
  http://www.eros-os.org/essays/capintro.html (a primer
if you're not familiar with the capabilities concept)

I think given what they've done so far, this could be a good model for a
Racket-based secure browser. I'm thinking why not implement an E version
(or something more lispy but inspired by E) as a #lang and using that to
implement all of or just the core functionality for the new browser.

Just adding a few of my cents about what I've seen out there in the wild.
Internet security is so hard, I think the only realistic route to getting
it right is to have some sort of unified security model that can be applied
to the whole browser while remaining simple and powerful enough to be able
to reason about the system security properties(and checked by an automated
proof tool)

Based on my own readings, it looks like the above desired security model is
made possible by using capabilities.


On Mon, Feb 3, 2014 at 5:04 PM, Neil Van Dyke  wrote:

> I'm just putting this idea out there, to see whether anyone is seriously
> interested...
>
> I'd like to see a few attempts to make a *viable* secure HTML5 Web
> browser, using Racket or Haskell.  HTML5 with JS, CSS layout, local
> storage, but no sound or video for now.  Fully GNU-style Free Software, and
> not biased by any commercial conflicts of interest.  Internally secure and
> stable in ways that current browsers clearly are not.
>
> If you need to ask why, look at the constant stream of Web browser
> security exploits, the *multi-gigabyte* source code bases of C and C++
> code, how Firefox's ongoing dependence on recent system library versions
> makes it hard for stable GNU/Linux distros to maintain a browser with
> security updates, etc.  Modern browser implementations have become
> monstrosities beyond what is necessary for the Web standards they have to
> support.  (Also, a viable Web browser is the current big implementation
> barrier to a general-purpose desktop/handheld OS that has the entire
> userspace implemented in Racket or Haskell, straight atop the Linux kernel.
>  But for now, think of it as a standalone app.)
>
> Myself, I'm *not* looking for a "hey, we can kinda make a toy browser in
> Racket good enough to get a paper out of it", nor "hey, a few people
> attempted Web browsers of some kind, I don't know how far they got, maybe
> we could start with one of those", nor "it can start out as a student
> exercise but take over the world 10 years later like Linux did."  Rather, I
> am looking for something that is done from the start to be viable in the
> near term as a primary desktop and handheld Web browser (excepting
> sound&video for now).
>
> If a couple people are seriously up to sacrificing their evenings and
> weekends on this for a year, then I can help with architecture and some key
> components, but I don't have time for attempts that aren't credible.  If we
> could get to the point that we've demonstrated brilliance and solid
> progress, and have a credible 6-month plan for completion of a viable
> browser, then there is an angle I could try to get funding, to pay the
> contributors to keep going at that point.  (I wouldn't try to get funding
> from the start, because the project wouldn't be taken seriously until we
> have something impressive to show, and the timeline is too long and
> unpredictable at the start.)
>
> Let me know if you'd like to talk about this.
>
> Separately, everyone should be encouraged to write a toy Web browser.
>  It's one of those toy programs that everyone should write, as a fun
> learning exercise.  (Previously, such programs have been text editor, CD
> player, Scheme interpreter, compiler, kernel, X window manager, etc.).  But
> this toy is separate from above, where I'm talking about something that is
> not a toy.
>
> Neil V.
>
> 
>  Racket Users list:
>  http://lists.racket-lang.org/users
>

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


Re: [racket] Common Lisp or Racket?

2013-11-12 Thread Alexander McLin
Racket is truely a great and cleaner Lisp. It's carved out its own path
that I find quite attractive and am enjoying my forays into Racket.

I would recommend you just get started with The Little Schemer to get a
taste, move on to How To Design Programs. There is a Coursera course that
uses HTDP, although I haven't taken it myself, is probably easier to stick
with than going through HTDP on your own. Realm of Racket is a nice book
but best read after you've already had some experience with a Lisp dialect.

Find or plan a project using Racket as your main coding language to help
you use and grow with it. For example I'm using Racket to develop programs
for the Coursera Bioinformatics Algorithm course.

However, I want to tell you that Common Lisp resources has plenty of
valuable information to learn even if you don't end up using CL regularly.
I'm not really a CL user but I still read a lot of CL books for interesting
Lisp history and techniques.

Racket is also especially nice that it has a strong academic and
theoretical community with high quality written papers which are good
source of material to understand more about language design and usage.


On Tue, Nov 12, 2013 at 11:56 AM, Lawrence Bottorff wrote:

> I'm your typical newbie who is hand-wringing over what direction to go in
> the general functional programming world. Lisp, Scheme, or Haskell?
>
> Of late I've been trying to get through the Barski book, "Land of Lisp,"
> but I'm really seeing now why Scheme was created: CL seems to have a ton of
> gnarl that is part-functional, part-whatever, leaving me wondering and
> neurotic. And so I'm trying to understand some esoteric, arcane Lisp
> printing/file management weirdness -- which I'm told is not proper
> functional style -- after I've just been introduced to yet another CL map
> variation, after (funcall thunk). So I guess I'd like your advice vis-a-vis
> Racket. Q: Is Racket "cleaner," or is full of pork too? Or have I just got
> the wrong book for a beginner?
>
> I understand that Barski is slavishly following the "let's get real stuff
> done" philosophy, but I'm not up to speed with functional yet to even know
> what's going on. Is your "Realm of Racket" better at this? I feel like I'm
> spinning my wheels at this point. . . .
>
> LB
>
>
>
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
>

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


Re: [racket] Racket VM in FPGAs

2013-10-19 Thread Alexander McLin
No problem, glad to have referred you to the paper, I hope it'll be useful.  
Just for everybody else on the list, the paper URL is 
http://dspace.mit.edu/handle/1721.1/6334

> On Oct 19, 2013, at 4:08 PM, Petr Samarin  wrote:
> 
> To be more specific, initially I want to replace the Java VM in JOP with a 
> Racket VM.
> JOP is great as a starting point because it has many useful things available 
> from the start: support for USB and serial interfaces to load the bytecode 
> from the PC, memory interfaces, floating point unit.
> 
> I haven't looked into the Scheme-79 paper yet (thanks for the reference by 
> the way!).
> 
>> On Oct 19, 2013, at 1:35 PM, Alexander McLin wrote:
>> I'd be interested in hearing how it's going!
>> 
>> Just curious, are you reusing ideas from Scheme-79, or starting off in an 
>> entirely different direction? From your original email, I assume you're 
>> using JOP as a springing board?
>> 
>> Alex
>> 
>>> On Oct 19, 2013, at 4:32 AM, Petr Samarin  wrote:
>>> 
>>> First I want to develop a small core (probably written in VHDL) that 
>>> supports a subset of Racket's bytecode.
>>> I don't want to target any specific board/FPGA so that it can be used 
>>> anywhere.
>>> But during development I will be testing the core on the board that I have 
>>> at home (DE2-70 from Terrasic).
>>> 
>>> When the basic version is done, I am also interested in how much 
>>> parallelism can be achieved on the VM level (adding more stacks, executing 
>>> several bytecodes at once, etc.).
>>> 
>>> Petr
>>> 
>>>> On Oct 19, 2013, at 12:26 AM, Neil Van Dyke wrote:
>>>> Petr, I will be very interested to hear how this project goes, including 
>>>> which FPGA you end up targeting, your application (large-scale parallel?  
>>>> low power?), and how speed compares to the JIT'd VM running on CPUs.
>>>> 
>>>> If you can use an open source toolchain, all the better, although a 
>>>> free-as-in-beer toolchain would also be OK if the open source ones don't 
>>>> support your target.  If it requires an expensive toolchain, it's still a 
>>>> good project, but much harder for other people to build on after you are 
>>>> done.  (The beefier FPGAs I was looking at in the last year, for numeric 
>>>> computing, seemed to require expensive proprietary toolchains.)
>>>> 
>>>> Neil V.
>>> 
>>> 
>>> 
>>> Racket Users list:
>>> http://lists.racket-lang.org/users
> 

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


Re: [racket] Racket VM in FPGAs

2013-10-19 Thread Alexander McLin
I'd be interested in hearing how it's going!

Just curious, are you reusing ideas from Scheme-79, or starting off in an 
entirely different direction? From your original email, I assume you're using 
JOP as a springing board?

Alex

> On Oct 19, 2013, at 4:32 AM, Petr Samarin  wrote:
> 
> First I want to develop a small core (probably written in VHDL) that supports 
> a subset of Racket's bytecode.
> I don't want to target any specific board/FPGA so that it can be used 
> anywhere.
> But during development I will be testing the core on the board that I have at 
> home (DE2-70 from Terrasic).
> 
> When the basic version is done, I am also interested in how much parallelism 
> can be achieved on the VM level (adding more stacks, executing several 
> bytecodes at once, etc.).
> 
> Petr
> 
>> On Oct 19, 2013, at 12:26 AM, Neil Van Dyke wrote:
>> Petr, I will be very interested to hear how this project goes, including 
>> which FPGA you end up targeting, your application (large-scale parallel?  
>> low power?), and how speed compares to the JIT'd VM running on CPUs.
>> 
>> If you can use an open source toolchain, all the better, although a 
>> free-as-in-beer toolchain would also be OK if the open source ones don't 
>> support your target.  If it requires an expensive toolchain, it's still a 
>> good project, but much harder for other people to build on after you are 
>> done.  (The beefier FPGAs I was looking at in the last year, for numeric 
>> computing, seemed to require expensive proprietary toolchains.)
>> 
>> Neil V.
> 
> 
> 
>  Racket Users list:
>  http://lists.racket-lang.org/users


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


Re: [racket] applicative order -- topic was: Re: Help with exception raising and testing

2013-08-28 Thread Alexander McLin
Thank you for the illuminating primer, Matt. I hadn't realized that it was
such a questionable term.




On Wed, Aug 28, 2013 at 12:54 PM, Matthias Felleisen
wrote:

>
> On Aug 28, 2013, at 12:33 PM, Grant Rettke wrote:
>
> > On Wed, Aug 28, 2013 at 11:04 PM, Matthias Felleisen
> >  wrote:
> >> For the record, there is no such thing as 'applicative order.' There is
> call-by-value and there is a humongous misunderstanding
> >> called 'applicative order'
> >
> > When authors use this term what do they cite as being the
> > authoritative source? How did people come up with using the term?
>
>
> A short history of PL and LC and evaluation order:
>
> * 1960ish: people discover the lc as a model of pl. But the lc by itself
> is not a pl, and they know that. For example, you can encode arithmetic in
> lc but that's bad. They also understand that lc per se does not nail down
> an evaluation function. For pragmatic reasons, it is clearly wrong to define
>
>  eval[[ e ]] = the normal form of e according to beta
>
> Otherwise you get infinite loops when the programs that you
>
> * over the he following decade: people make two different compromises:
>
>  [1] they stop evaluating when they find a lambda but otherwise use beta
>
>  [2] they evaluate the argument before they evaluate a function application
> Algol 60 introduces the by-value variant as
> A(int x) value x; as short for A(int x); x := x;
> with the understanding that := is strict on the rhs.
>
> * in parallel: mathematicians think that this is about a strategy for
> evaluation lambda terms and explore a whole range of evaluation strategy.
> An ES is a function from a lambda term with at least one beta redex to a
> specific beta redex. Applicative order is one of these.
>
> * 1970ish: People begin to understand that 'applicative' does not address
> the termination issue. Confusion reigns.
>
> * 1973: Plotkin writes the definitive paper on the issue of relating LC to
> notions of CBName and CBValue. It appears in TCS:
>
> Call-by-name, call-by-value, and the lambda calculus.
>
> It shows how the idea of evaluation order and the idea of a calculus
> relate to each other and sets out general criteria. Then it shows that two
> different calculi relate to the specified evaluation function according to
> these criteria.
>
> * I later showed in my dissertation that these criteria also apply to
> extensions of the model with assignment and control.
>
> * Crank and I followed up with a paper that shows how Plotkin's criteria
> scale to call-by-reference/pass-by-worth, call-by-copy-in/out, etc. So
> Plotkin's criteria are neither whimsical nor a fluke. It is possible to
> work out this connection for any combination.
>
> * In a nutshell, however, the idea of evaluation strategy for LC relates
> to the idea of evaluation order in PLs only in a highly superficial manner.
>
> * Sadly SICP continues to propagate this misunderstanding and people keep
> for falling for it because the book is intriguing in other ways.
>
> So if you wish to connect LC and PL and speak about order, please study
> the above citations. The whole discussion is summarized in the first part
> of the REDEX book (see redex.racket-lang.org).
>
> -- Matthias
>
>
>
>
>
>
>
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users
>

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


Re: [racket] applicative order -- topic was: Re: Help with exception raising and testing

2013-08-28 Thread Alexander McLin
Thank you for the correction. I will be more careful in the future.


On Wed, Aug 28, 2013 at 1:08 PM, Matthias Felleisen wrote:

>
> No problem.
>
> While we are on names. We use
>  -- "Matt" for Matthew Might, a Utah researcher who also uses Racket;
>  -- "Matthew" for Matthew Flatt, the CEO of PLT Design, Inc, creator of
> Racket, and ruler of the kingdom
>  -- "Matthias" for me, which yes, is a form of Matthew (used in Germanic
> and Hispanic contexts with various spellings).
>
>
>
>
>
>
> On Aug 28, 2013, at 1:02 PM, Alexander McLin wrote:
>
> Thank you for the illuminating primer, Matt. I hadn't realized that it was
> such a questionable term.
>
>
>
>
> On Wed, Aug 28, 2013 at 12:54 PM, Matthias Felleisen  > wrote:
>
>>
>> On Aug 28, 2013, at 12:33 PM, Grant Rettke wrote:
>>
>> > On Wed, Aug 28, 2013 at 11:04 PM, Matthias Felleisen
>> >  wrote:
>> >> For the record, there is no such thing as 'applicative order.' There
>> is call-by-value and there is a humongous misunderstanding
>> >> called 'applicative order'
>> >
>> > When authors use this term what do they cite as being the
>> > authoritative source? How did people come up with using the term?
>>
>>
>> A short history of PL and LC and evaluation order:
>>
>> * 1960ish: people discover the lc as a model of pl. But the lc by itself
>> is not a pl, and they know that. For example, you can encode arithmetic in
>> lc but that's bad. They also understand that lc per se does not nail down
>> an evaluation function. For pragmatic reasons, it is clearly wrong to define
>>
>>  eval[[ e ]] = the normal form of e according to beta
>>
>> Otherwise you get infinite loops when the programs that you
>>
>> * over the he following decade: people make two different compromises:
>>
>>  [1] they stop evaluating when they find a lambda but otherwise use beta
>>
>>  [2] they evaluate the argument before they evaluate a function
>> application
>> Algol 60 introduces the by-value variant as
>> A(int x) value x; as short for A(int x); x := x;
>> with the understanding that := is strict on the rhs.
>>
>> * in parallel: mathematicians think that this is about a strategy for
>> evaluation lambda terms and explore a whole range of evaluation strategy.
>> An ES is a function from a lambda term with at least one beta redex to a
>> specific beta redex. Applicative order is one of these.
>>
>> * 1970ish: People begin to understand that 'applicative' does not address
>> the termination issue. Confusion reigns.
>>
>> * 1973: Plotkin writes the definitive paper on the issue of relating LC
>> to notions of CBName and CBValue. It appears in TCS:
>>
>> Call-by-name, call-by-value, and the lambda calculus.
>>
>> It shows how the idea of evaluation order and the idea of a calculus
>> relate to each other and sets out general criteria. Then it shows that two
>> different calculi relate to the specified evaluation function according to
>> these criteria.
>>
>> * I later showed in my dissertation that these criteria also apply to
>> extensions of the model with assignment and control.
>>
>> * Crank and I followed up with a paper that shows how Plotkin's criteria
>> scale to call-by-reference/pass-by-worth, call-by-copy-in/out, etc. So
>> Plotkin's criteria are neither whimsical nor a fluke. It is possible to
>> work out this connection for any combination.
>>
>> * In a nutshell, however, the idea of evaluation strategy for LC relates
>> to the idea of evaluation order in PLs only in a highly superficial manner.
>>
>> * Sadly SICP continues to propagate this misunderstanding and people keep
>> for falling for it because the book is intriguing in other ways.
>>
>> So if you wish to connect LC and PL and speak about order, please study
>> the above citations. The whole discussion is summarized in the first part
>> of the REDEX book (see redex.racket-lang.org).
>>
>> -- Matthias
>>
>>
>>
>>
>>
>>
>>
>> 
>>   Racket Users list:
>>   http://lists.racket-lang.org/users
>>
>
>
>

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


Re: [racket] applicative order -- topic was: Re: Help with exception raising and testing

2013-08-28 Thread Alexander McLin
I would like to understand this some more.

My understanding of applicative order is also connected with normal order,
I thought applicative order just means that all arguments given to a
procedure are always evaluated before the procedure is applied, the
left-right or right-left detail is irrelevant. Likewise normal order is the
opposite, arguments are only evaluated when they are actually needed,
regardless of left-right or right-left ordering.

In fact I learned that in SCIP, so I need to check when the edition I have
was published to see how old it really is.

Alex


On Wed, Aug 28, 2013 at 11:04 AM, Matthias Felleisen
wrote:

>
> On Aug 27, 2013, at 8:48 PM, Galler wrote:
>
> > Racket uses applicative order
>
>
> For the record, there is no such thing as 'applicative order.' There is
> call-by-value and there is a humongous misunderstanding called 'applicative
> order' in the 1960s and 1970s that was fixed by Plotkin's 1973 paper on
> "call-by-name, call-by-value, and the lc" in TCS. There are stone-aged
> authors who can't resist using this terminology but we should be
> enlightened enough to know that this is a bogus term w/o well-defined
> meaning :-)
>
> -- Matthias (heart-felt as you can tell)
>
>
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users
>

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