[plt-dev] super class in error messages

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Oct 29 19:10:40 EDT 2009

It looks ok to me.

The original convention for error messages was to precede values in the
error message with ":". But that never worked very well, anyway, so I
don't think it matters.

The "~a"s for printing class values really should be "~e" everywhere.
(The "~a"s for method names should stay "~a", since they aren't meant
to be printed as values.)

At Thu, 29 Oct 2009 14:41:58 -0600, Jon Rafkind wrote:
> Anyone mind if I apply this patch? It prints the super class value in 
> error messages. Two things that might need to be changed first:
> 1. other errors print super using ~e, whereas I use ~a. Is that important?
> 2. usually the error message is some text followed by values, as in 
> "super class blah blah: ~a~a~a" but I put the super value right after 
> the words 'superclass': "superclass ~a blah blah blah: ~a~a".
> Index: class-internal.ss
> ===================================================================
> --- class-internal.ss	(revision 16450)
> +++ class-internal.ss	(working copy)
> @@ -1919,7 +1919,8 @@
>  	  (let loop ([ids public-names][p (class-method-width super)])
>  	    (unless (null? ids)
>  	      (when (hash-ref method-ht (car ids) #f)
> -		(obj-error 'class* "superclass already contains method: ~a~a" 
> +		(obj-error 'class* "superclass ~a already contains method: 
> ~a~a" 
> +               super
>  			   (car ids)
>  			   (for-class name)))
>  	      (hash-set! method-ht (car ids) p)
> @@ -1928,7 +1929,8 @@
>  	  (let loop ([ids public-field-names][p (class-field-width super)])
>  	    (unless (null? ids)
>  	      (when (hash-ref field-ht (car ids) #f)
> -		(obj-error 'class* "superclass already contains field: ~a~a" 
> +		(obj-error 'class* "superclass ~a already contains field: 
> ~a~a" 
> +               super
>  			   (car ids)
>  			   (for-class name)))
>  	      (hash-set! field-ht (car ids) p)
> @@ -1937,7 +1939,8 @@
>  	;; Check that superclass has expected fields
>  	(for-each (lambda (id)
>  		    (unless (hash-ref field-ht id #f)
> -		      (obj-error 'class* "superclass does not provide field: 
> ~a~a" 
> +		      (obj-error 'class* "superclass ~a does not provide 
> field: ~a~a" 
> +                 super
>  				 id
>  				 (for-class name))))
>  		  inherit-field-names)
> @@ -2120,8 +2123,9 @@
>  					      (or (vector-ref vec (sub1 
> (vector-length vec)))
>  						  (obj-error 'class* 
>  							     (string-append
> -							      "superclass 
> method for override, overment, inherit/super, "
> +							      "superclass ~a 
> method for override, overment, inherit/super, "
>  							      "or rename-super 
> is not overrideable: ~a~a")
> +                                 super
>  							     mname
>  							     (for-class name)))
>  					      (vector-ref (class-methods 
> super) index))))
> @@ -2152,8 +2156,9 @@
>                                                        (unless aug-ok?
>                                                          (obj-error 'class* 
>                                                                     
> (string-append
> -                                                                    
> "superclass method for augride, augment, inherit/inner, "
> +                                                                    
> "superclass ~a method for augride, augment, inherit/inner, "
>                                                                      "or 
> rename-inner method is not augmentable: ~a~a")
> +                                                                   super
>                                                                     mname
>                                                                     (for-class 
> name))))))])
>                                             (for-each (check-aug #f) 
> @@ -2738,12 +2743,14 @@
>                 c inited? leftovers ; merely passed through to 
> continue-make-super
>                 named-args)
>                (unless (unbox inited?)
> -                (obj-error 'instantiate "superclass initialization not 
> invoked by initialization~a"
> +                (obj-error 'instantiate "superclass ~a initialization not 
> invoked by initialization~a"
> +                           super
>                             (for-class (class-name c))))))))))
>  
>    (define (continue-make-super o c inited? leftovers by-pos-args 
> new-named-args)
>      (when (unbox inited?)
> -      (obj-error 'instantiate "superclass already initialized by class 
> initialization~a"
> +      (obj-error 'instantiate "superclass ~a already initialized by class 
> initialization~a"
> +                 super
>  		 (for-class (class-name c))))
>      (set-box! inited? #t)
>      (let ([named-args (if (eq? 'list (class-init-mode c))
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-dev


Posted on the dev mailing list.