provide/contract'ed funs can't be used in student languages #145

Closed
racket-bug-submit opened this Issue Mar 9, 2012 · 12 comments

Projects

None yet

3 participants

@racket-bug-submit
Collaborator
Originally submitted by John Clements clements@racket-lang.org on: Tue Oct 04 01:28:01 -0400 2011
If a function is provided with a contract,
calling it in a student language signals
the error

function call: expected a function after the open parenthesis, but found a variable
Steps to Reproduce:
cat > ~/plt/collects/stepper/bogus.rkt
#lang racket

(provide/contract [bogus (-> number? number?)])

(define (bogus x) x) 

Then, open a new buffer in DrR, set the 
language level to Beginning Student, and 
evaluate this program:

(require stepper/bogus)

(bogus 3)

See the error mentioned above.
Release:
5.1.3.11--2011-10-01(79fbc97/g)
Environment:
macosx "Darwin oiseau.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun  7 16:33:36 PDT
 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386" (x86_64-macosx/3m) (get-display-depth) = 32
Human Language: english
(current-memory-use) 435567704
Links: (links) = (); (links #:user? #f) = (); (links #:root? #t) = (); (links #:user? #f
 #:root? #t) = ()


Collections:
("/Users/clements/clements/collects"
 (".gitignore" "badger" "file-size-checker" "info-domain" "jbc-gnucash" "mboxrd-read"
 "midi" "mnemisis" "projector" "shelly" "template-tester" "txomp" "web-utilities"))
("/Users/clements/matthias/collects"
 (non-existent-path))
("/Users/clements/Library/Racket/5.1.3.11/collects"
 (non-existent-path))
("/Users/clements/plt/collects"
 (".gitignore" "2htdp" "algol60" "at-exp" "browser" "combinator-parser" "compiler"
 "config" "data" "datalog" "db" "defaults" "deinprogramm" "drracket" "drscheme" "dynext"
 "embedded-gui" "eopl" "errortrace" "ffi" "file" "framework" "frtime" "games" "graphics"
 "gui-debugger" "guibuilder" "handin-client" "handin-server" "help" "hierlist" "honu"
 "htdp" "html" "icons" "info-domain" "lang" "launcher" "lazy" "macro-debugger" "make"
 "meta" "mred" "mrlib" "mysterx" "mzcom" "mzlib" "mzscheme" "net" "openssl" "parser-tools"
 "picturing-programs" "plai" "planet" "plot" "preprocessor" "profile" "r5rs" "r6rs"
 "racket" "racklog" "rackunit" "raco" "reader" "readline" "redex" "repo-time-stamp" "rnrs"
 "s-exp" "scheme" "schemeunit" "scribble" "scribblings" "scriblib" "setup" "sgl" "sirmail"
 "slatex" "slideshow" "srfi" "srpersist" "stepper" "string-constants" "swindle" "syntax"
 "syntax-color" "teachpack" "test-box-recovery" "test-engine" "tests" "tex2page" "texpict"
 "trace" "typed" "typed-racket!
 " "typed-scheme" "unstable" "version" "waterworld" "web-server" "wxme" "xml" "xrepl"))

Computer Language: (("Teaching Languages" "How to Design Programs" "Beginning Student")
 (#(#t constructor repeating-decimal #f #t none) #f ()))
This bug was converted from Gnats bug 12254.

[anon-submit clements AT racket-lang.org]

@racket-bug-submit
Collaborator
On Tue, 4 Oct 2011 06:52:14 -0400, matthias@ccs.neu.edu wrote:
It works fine in Intermediate, and for Beginner I think it shouldn't work. 

On Oct 4, 2011, at 1:28 AM, clements@racket-lang.org wrote:

A new problem report is waiting at
http://bugs.racket-lang.org/query/?cmd=view&pr=12254

Reported by John Clements for release: 5.1.3.11--2011-10-01(79fbc97/g)

*** Description:
If a function is provided with a contract,
calling it in a student language signals
the error

function call: expected a function after the open parenthesis, but found a variable

*** How to repeat:
cat > ~/plt/collects/stepper/bogus.rkt
#lang racket

(provide/contract [bogus (-> number? number?)])

(define (bogus x) x)

Then, open a new buffer in DrR, set the
language level to Beginning Student, and
evaluate this program:

(require stepper/bogus)

(bogus 3)

See the error mentioned above.

*** Environment:
macosx "Darwin oiseau.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386" (x86_64-macosx/3m) (get-display-depth) = 32
Human Language: english
(current-memory-use) 435567704
Links: (links) = (); (links #:user? #f) = (); (links #:root? #t) = (); (links #:user? #f #:root? #t) = ()

Collections:
("/Users/clements/clements/collects"
(".gitignore" "badger" "file-size-checker" "info-domain" "jbc-gnucash" "mboxrd-read" "midi" "mnemisis" "projector" "shelly" "template-tester" "txomp" "web-utilities"))
("/Users/clements/matthias/collects"
(non-existent-path))
("/Users/clements/Library/Racket/5.1.3.11/collects"
(non-existent-path))
("/Users/clements/plt/collects"
(".gitignore" "2htdp" "algol60" "at-exp" "browser" "combinator-parser" "compiler" "config" "data" "datalog" "db" "defaults" "deinprogramm" "drracket" "drscheme" "dynext" "embedded-gui" "eopl" "errortrace" "ffi" "file" "framework" "frtime" "games" "graphics" "gui-debugger" "guibuilder" "handin-client" "handin-server" "help" "hierlist" "honu" "htdp" "html" "icons" "info-domain" "lang" "launcher" "lazy" "macro-debugger" "make" "meta" "mred" "mrlib" "mysterx" "mzcom" "mzlib" "mzscheme" "net" "openssl" "parser-tools" "picturing-programs" "plai" "planet" "plot" "preprocessor" "profile" "r5rs" "r6rs" "racket" "racklog" "rackunit" "raco" "reader" "readline" "redex" "repo-time-stamp" "rnrs" "s-exp" "scheme" "schemeunit" "scribble" "scribblings" "scriblib" "setup" "sgl" "sirmail" "slatex" "slideshow" "srfi" "srpersist" "stepper" "string-constants" "swindle" "syntax" "syntax-color" "teachpack" "test-box-recovery" "test-engine" "tests" "tex2page" "texpict" "trace" "typed" "typed-racket!
" "typed-scheme" "unstable" "version" "waterworld" "web-server" "wxme" "xml" "xrepl"))

Computer Language: (("Teaching Languages" "How to Design Programs" "Beginning Student") (#(#t constructor repeating-decimal #f #t none) #f ()))

@racket-bug-submit
Collaborator
On Tue, 04 Oct 2011 07:13:39 -0400, matthias assigned this bug to matthias
@racket-bug-submit
Collaborator
On Tue, 04 Oct 2011 07:13:39 -0400, matthias wrote:

not a bug

@racket-bug-submit
Collaborator
On Tue, 4 Oct 2011 07:12:44 -0400, matthias@ccs.neu.edu wrote:

p.s. The reason they shouldn't work is that they violate Guillaume's guidelines for error reporting.

(This also applies at the Intermediate level but there I think we can tolerate it.)

On Oct 4, 2011, at 6:52 AM, Matthias Felleisen wrote:

It works fine in Intermediate, and for Beginner I think it shouldn't work.

On Oct 4, 2011, at 1:28 AM, clements@racket-lang.org wrote:

A new problem report is waiting at
http://bugs.racket-lang.org/query/?cmd=view&pr=12254

Reported by John Clements for release: 5.1.3.11--2011-10-01(79fbc97/g)

*** Description:
If a function is provided with a contract,
calling it in a student language signals
the error

function call: expected a function after the open parenthesis, but found a variable

*** How to repeat:
cat > ~/plt/collects/stepper/bogus.rkt
#lang racket

(provide/contract [bogus (-> number? number?)])

(define (bogus x) x)

Then, open a new buffer in DrR, set the
language level to Beginning Student, and
evaluate this program:

(require stepper/bogus)

(bogus 3)

See the error mentioned above.

*** Environment:
macosx "Darwin oiseau.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386" (x86_64-macosx/3m) (get-display-depth) = 32
Human Language: english
(current-memory-use) 435567704
Links: (links) = (); (links #:user? #f) = (); (links #:root? #t) = (); (links #:user? #f #:root? #t) = ()

Collections:
("/Users/clements/clements/collects"
(".gitignore" "badger" "file-size-checker" "info-domain" "jbc-gnucash" "mboxrd-read" "midi" "mnemisis" "projector" "shelly" "template-tester" "txomp" "web-utilities"))
("/Users/clements/matthias/collects"
(non-existent-path))
("/Users/clements/Library/Racket/5.1.3.11/collects"
(non-existent-path))
("/Users/clements/plt/collects"
(".gitignore" "2htdp" "algol60" "at-exp" "browser" "combinator-parser" "compiler" "config" "data" "datalog" "db" "defaults" "deinprogramm" "drracket" "drscheme" "dynext" "embedded-gui" "eopl" "errortrace" "ffi" "file" "framework" "frtime" "games" "graphics" "gui-debugger" "guibuilder" "handin-client" "handin-server" "help" "hierlist" "honu" "htdp" "html" "icons" "info-domain" "lang" "launcher" "lazy" "macro-debugger" "make" "meta" "mred" "mrlib" "mysterx" "mzcom" "mzlib" "mzscheme" "net" "openssl" "parser-tools" "picturing-programs" "plai" "planet" "plot" "preprocessor" "profile" "r5rs" "r6rs" "racket" "racklog" "rackunit" "raco" "reader" "readline" "redex" "repo-time-stamp" "rnrs" "s-exp" "scheme" "schemeunit" "scribble" "scribblings" "scriblib" "setup" "sgl" "sirmail" "slatex" "slideshow" "srfi" "srpersist" "stepper" "string-constants" "swindle" "syntax" "syntax-color" "teachpack" "test-box-recovery" "test-engine" "tests" "tex2page" "texpict" "trace" "typed" "typed-racket!
" "typed-scheme" "unstable" "version" "waterworld" "web-server" "wxme" "xml" "xrepl"))

Computer Language: (("Teaching Languages" "How to Design Programs" "Beginning Student") (#(#t constructor repeating-decimal #f #t none) #f ()))

@racket-bug-submit
Collaborator
On Wed, 5 Oct 2011 22:55:41 -0700, clements@brinckerhoff.org wrote:
On Oct 4, 2011, at 4:12 AM, Matthias Felleisen wrote:

p.s. The reason they shouldn't work is that they violate Guillaume's guidelines for error reporting.

(This also applies at the Intermediate level but there I think we can tolerate it.)

I see what you're saying, and by the same token, the existing error message:

>>> function call: expected a function after the open parenthesis, but found a variable

Is pretty definitely unacceptable.  

Right?

John
@racket-bug-submit
Collaborator
On Thu, 6 Oct 2011 07:22:50 -0400, matthias@ccs.neu.edu wrote:
Yes, and I have no clue what to do about it. 

This is actually research: how things from two languages exchange values and don't violate invariants (in this case error message invariants).

On Oct 6, 2011, at 1:55 AM, John Clements wrote:

On Oct 4, 2011, at 4:12 AM, Matthias Felleisen wrote:

p.s. The reason they shouldn't work is that they violate Guillaume's guidelines for error reporting.

(This also applies at the Intermediate level but there I think we can tolerate it.)

I see what you're saying, and by the same token, the existing error message:

function call: expected a function after the open parenthesis, but found a variable

Is pretty definitely unacceptable.

Right?

John

@racket-bug-submit
Collaborator
On Thu, 6 Oct 2011 10:02:04 -0700, clements@brinckerhoff.org wrote:
On Oct 6, 2011, at 4:22 AM, Matthias Felleisen wrote:

Yes, and I have no clue what to do about it.

This is actually research: how things from two languages exchange values and don't violate invariants (in this case error message invariants).

In general, I see that this is an interesting problem. Is it not possible ... okay, let me go look at the code.

Oh, I see:

    ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; application (beginner and intermediate)
    ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    ;; For beginner:

    ;; #%app should never happen in beginner. Primitive operations and
    ;; defined functions turn into syntax that handle application
    ;; forms.  The only vaguely legitimate application would involve a
    ;; poorly implemented teachpack that exports functions instead of
    ;; primitive operators. Also, #%app is unavoidable in the REPL.

    ;; An #%app might happen "temporarily" if it appears at the top
    ;; level before the corresponding function definition. To provide
    ;; a good error message, we need to wait, and that's what
    ;; beginner-app-delay does.

This suggests to me that no requires can naively be expected to work correctly in beginner, unless they're specifically designed, so that every looks-like-an-application is actually non-#%app syntax. I don't know if this comment is current--some things are working that this comment suggests shouldn't--but my takeaway is simply that I should move my students to intermediate and get on with my class.

Thanks!

John
@racket-bug-submit
Collaborator
On Thu, 6 Oct 2011 21:03:29 -0400, matthias@ccs.neu.edu wrote:
On Oct 6, 2011, at 1:02 PM, John Clements wrote:

This suggests to me that no requires can naively be expected to work correctly in beginner, unless they're specifically designed, so that every looks-like-an-application is actually non-#%app syntax. I don't know if this comment is current--some things are working that this comment suggests shouldn't--but my takeaway is simply that I should move my students to intermediate and get on with my class.

Sounds right. 
@racket-bug-submit
Collaborator
On Thu, 6 Oct 2011 23:32:01 -0400, bloch@adelphi.edu wrote:
On Oct 6, 2011, at 1:02 PM, "John Clements" <clements@brinckerhoff.org> wrote:

This suggests to me that no requires can naively be expected to work correctly in beginner, unless they're specifically designed, so that every looks-like-an-application is actually non-#%app syntax. I don't know if this comment is current--some things are working that this comment suggests shouldn't--but my takeaway is simply that I should move my students to intermediate and get on with my class.

Ouch!

Is there a way to "wrap" an imported function in such syntax? And if so, can BSL's version of "require" do that automatically for all the provided functions?

Stephen Bloch
sbloch@adelphi.edu
>
@samth
Owner
samth commented Mar 12, 2012

\uud834\udd1e

@elibarzilay
Collaborator

bleh

@elibarzilay
Collaborator

bleh bleh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment