[plt-dev] Re: [plt-scheme] New contract-related features

From: Stevie Strickland (sstrickl at ccs.neu.edu)
Date: Sun Feb 15 22:51:33 EST 2009

On Feb 15, 2009, at 6:51 PM, Matthias Felleisen wrote:
> I am sorry, but
>
>> Welcome to DrScheme, version 4.1.4.3-svn13feb2009 [3m].
>> Language: Module; memory limit: 128 megabytes.
>> . begin (possibly implicit): no expression after a sequence of  
>> internal definitions in: ((define-syntax current-contract-region11  
>> (convert-renamer (λ (stx) (syntax (quote (region f1)))))) (expand- 
>> ssp-body (current-contract-region1) (current-contract-region11)  
>> (with-contract-helper #<procedure:syntax-introducer> (quote (region  
>> f1)) ((g number?)) () (define g 10))))
>> >
>
> is indefensible.

Well, with the following patch, for:

   (define (f x)
     (with-contract f1
       ((y number?))
       (define y x)))

I get:

   begin (possibly implicit): no expression after a sequence of  
internal definitions in: ((with-contract f1 ((y number?)) (define y x)))

However, I don't know the C internals well enough to know whether this  
patch is good as-is or if there'd be any strange effects in having  
just a straight alias like this and there's some bookkeeping that'd  
need to be managed. It's just something I tried to see if this is  
where such a change would need to be made.

Stevie

Index: src/mzscheme/src/eval.c
===================================================================
--- src/mzscheme/src/eval.c	(revision 13652)
+++ src/mzscheme/src/eval.c	(working copy)
@@ -6313,7 +6313,7 @@
     It is espcailly ugly because we have to expand macros
     before deciding what we have. */
  {
-  Scheme_Object *first, *rib, *ctx, *ectx;
+  Scheme_Object *first, *rib, *ctx, *ectx, *orig = forms;
    Scheme_Comp_Env *xenv = NULL;
    Scheme_Compile_Info recs[2];
    DupCheckRecord r;
@@ -6595,7 +6595,7 @@
  	more = 0;
        } else {
  	/* Empty body: illegal. */
-	scheme_wrong_syntax(scheme_begin_stx_string, NULL, forms,
+	scheme_wrong_syntax(scheme_begin_stx_string, NULL, orig,
  			    "no expression after a sequence of internal definitions");
        }
      }

Posted on the dev mailing list.