[plt-scheme] (v4) wildcard not allowed in expression

From: Jos Koot (jos.koot at telefonica.net)
Date: Mon Jun 23 21:47:28 EDT 2008

Correct. _ has become a wild-card that is bound to a syntax that does not want to be called. You can no longer use _ like other symbols. Hence the wild card may appear in a pattern, but you should not use it in a template. That is in R6RS or PLT 4. In 371 _ was just a symbol like any other one. Why in Pretty Big it still works as an ordinary symbol in old fashion, I don't know.
If you want a symbol that is associated with the name of the syntax use anything else than a wild-card. The wild-card is not bound to a pattern element (except may be in Pretty Big, I don't know)
Jos
  ----- Original Message ----- 
  From: YC 
  To: Jos Koot 
  Cc: pltscheme 
  Sent: Tuesday, June 24, 2008 3:31 AM
  Subject: Re: [plt-scheme] (v4) wildcard not allowed in expression


  I used to write _ in the expression as a shorthand to the head of the pattern as follows:


  Welcome to DrScheme, version 371 [3m].
  Language: Pretty Big (includes MrEd and Advanced Student).
  > (define-syntax (and2 stx)
    (syntax-case stx () 
      ((_ a b c d ...)
       #'(_ a (_ b c d ...))) ;;; works 
      ((_ a b)
       #'(if a b #f))))
  > (and2 #t #t #t)
  #t
  > (and2 #t #t #t #f)
  #f


  In v4 - the above causes the error of "_: wildcard not allowed as an expression in (_ #t (_ #t #f))".   I noticed this error using emacs & v4 on Linux.  

  I tried to replicate it using DrScheme (on Windows) and found that with the Module language it will cause the same error, but if using legacy language of Pretty Big, it appears to be behave the same as in 37x. 



  Welcome to DrScheme, version 4.0 [3m].
  Language: Module; memory limit: 128 megabytes.
  > (and2 #t #t #f) ;; throw error 
  . _: wildcard not allowed as an expression in: (_ #t (_ #t #f))



  Welcome to DrScheme, version 4.0 [3m].
  Language: Pretty Big (includes MrEd and Advanced Student); memory limit: 128 megabytes.
  > (and #t #t #f) ;; works
  #f





  On Mon, Jun 23, 2008 at 5:44 PM, Jos Koot <jos.koot at telefonica.net> wrote:

    May be you missed the fact that _ has become a wild-card.
    Jos
      ----- Original Message ----- 
      From: Jos Koot 
      To: YC ; pltscheme 
      Sent: Tuesday, June 24, 2008 2:39 AM
      Subject: Re: [plt-scheme] (v4) wildcard not allowed in expression


      It works for me though:

      #lang scheme

      (define-syntax x
       (syntax-rules ()
        ((_ 1 _) 'one)
        ((_ _ 2) 'two)))

      (x 1 monkey) ; one
      (x monkey 2) ; two

      Welcome to DrScheme, version 4.0.0.1-svn16jun2008 [3m].
      Language: Module.

      Jos
        ----- Original Message ----- 
        From: YC 
        To: pltscheme 
        Sent: Tuesday, June 24, 2008 12:32 AM
        Subject: [plt-scheme] (v4) wildcard not allowed in expression


        Hi - 

        It seems that in v4 `_` can no longer exist in the expression position for syntax-case, is there a reason for the change? 

        Thanks,
        yc




------------------------------------------------------------------------


        _________________________________________________
          For list-related administrative tasks:
          http://list.cs.brown.edu/mailman/listinfo/plt-scheme



--------------------------------------------------------------------------


      _________________________________________________
        For list-related administrative tasks:
        http://list.cs.brown.edu/mailman/listinfo/plt-scheme


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20080624/bf72da4c/attachment.html>

Posted on the users mailing list.