public inbox for cgen@sourceware.org
 help / color / mirror / Atom feed
* PATCH: Handle symbols in messages
@ 2005-01-20 22:59 Jim Blandy
  2005-01-21  0:26 ` Doug Evans
  0 siblings, 1 reply; 4+ messages in thread
From: Jim Blandy @ 2005-01-20 22:59 UTC (permalink / raw)
  To: cgen


I've committed the following.  There are many more places where concat
is needed, but cgen now runs with '-v -v -v -v'; we can fix others as
we find them.

2005-01-20  Jim Blandy  <jimb@redhat.com>

	* utils.scm (concat): New function.
	* insn.scm (-sub-insn-make!): Use concat instead of string-map.
	* rtl.scm (rtx-dump): Same.
	* semantics.scm (semantic-compile): Same.

Index: cgen/insn.scm
===================================================================
RCS file: /cvs/cvsfiles/devo/cgen/insn.scm,v
retrieving revision 1.58
diff -c -p -r1.58 insn.scm
*** cgen/insn.scm	20 Jul 2003 18:06:02 -0000	1.58
--- cgen/insn.scm	20 Jan 2005 22:52:04 -0000
***************
*** 271,280 ****
  	 (obj:name insn)
  	 ":"
  	 (string-map (lambda (op newval)
! 		       (string-append " "
! 				      (obj:name op)
! 				      "="
! 				      (obj:name newval)))
  		     anyof-operands new-values)
  	 " ...\n")
  
--- 271,280 ----
  	 (obj:name insn)
  	 ":"
  	 (string-map (lambda (op newval)
! 		       (concat " "
! 			       (obj:name op)
! 			       "="
! 			       (obj:name newval)))
  		     anyof-operands new-values)
  	 " ...\n")
  
Index: cgen/rtl.scm
===================================================================
RCS file: /cvs/cvsfiles/devo/cgen/rtl.scm,v
retrieving revision 1.53
diff -c -p -r1.53 rtl.scm
*** cgen/rtl.scm	20 Jul 2003 18:06:02 -0000	1.53
--- cgen/rtl.scm	20 Jan 2005 22:52:04 -0000
***************
*** 786,796 ****
  
  (define (rtx-dump rtx)
    (cond ((list? rtx) (map rtx-dump rtx))
! 	((object? rtx) (string-append "#<object "
! 				      (object-class-name rtx)
! 				      " "
! 				      (obj:name rtx)
! 				      ">"))
  	(else rtx))
  )
  
--- 786,796 ----
  
  (define (rtx-dump rtx)
    (cond ((list? rtx) (map rtx-dump rtx))
! 	((object? rtx) (concat "#<object "
! 			       (object-class-name rtx)
! 			       " "
! 			       (obj:name rtx)
! 			       ">"))
  	(else rtx))
  )
  
Index: cgen/semantics.scm
===================================================================
RCS file: /cvs/cvsfiles/devo/cgen/semantics.scm,v
retrieving revision 1.19
diff -c -p -r1.19 semantics.scm
*** cgen/semantics.scm	20 Jul 2003 18:06:02 -0000	1.19
--- cgen/semantics.scm	20 Jan 2005 22:52:04 -0000
***************
*** 798,808 ****
  		  sorted-outs out-op-nums)
  
  	(let ((dump (lambda (op)
! 		      (string-append "  "
! 				     (obj:name op)
! 				     " "
! 				     (number->string (op:num op))
! 				     "\n"))))
  	  (logit 4
  		 "Input operands:\n"
  		 (map dump sorted-ins)
--- 798,808 ----
  		  sorted-outs out-op-nums)
  
  	(let ((dump (lambda (op)
! 		      (concat "  "
! 			      (obj:name op)
! 			      " "
! 			      (number->string (op:num op))
! 			      "\n"))))
  	  (logit 4
  		 "Input operands:\n"
  		 (map dump sorted-ins)
Index: cgen/utils.scm
===================================================================
RCS file: /cvs/cvsfiles/devo/cgen/utils.scm,v
retrieving revision 1.82
diff -c -p -r1.82 utils.scm
*** cgen/utils.scm	16 Dec 2004 21:52:37 -0000	1.82
--- cgen/utils.scm	20 Jan 2005 22:52:04 -0000
***************
*** 85,90 ****
--- 85,96 ----
      (write (spaces n) port))
  )
  
+ ; Concatenate all the arguments and make a string.  Symbols are
+ ; converted to strings.
+ (define (concat . sequences)
+   (define (sequence->string o) (if (symbol? o) (symbol->string o) o))
+   (apply string-append (map sequence->string sequences)))
+ 
  ; Often used idiom.
  
  (define (string-map fn . args) (apply string-append (apply map (cons fn args))))

^ permalink raw reply	[flat|nested] 4+ messages in thread

* PATCH: Handle symbols in messages
  2005-01-20 22:59 PATCH: Handle symbols in messages Jim Blandy
@ 2005-01-21  0:26 ` Doug Evans
  2005-01-22  2:44   ` Jim Blandy
  0 siblings, 1 reply; 4+ messages in thread
From: Doug Evans @ 2005-01-21  0:26 UTC (permalink / raw)
  To: Jim Blandy; +Cc: cgen

fwiw, while string-concat might not clearly specify the operation
(though I don't have a problem with it), `concat' seems too generic
(or at least not string-specific enough in the way that the rest of
the string functions are so named).

string-map is to map,
as string-list is to list,
as string-<mumble> is to concat.

concat mightn't make sense outside of strings (and thus why have the
string- prefix ...), but why preclude symbol-concat? (etc.)

How about string-concat?

 > diff -c -p -r1.82 utils.scm
 > *** cgen/utils.scm	16 Dec 2004 21:52:37 -0000	1.82
 > --- cgen/utils.scm	20 Jan 2005 22:52:04 -0000
 > ***************
 > *** 85,90 ****
 > --- 85,96 ----
 >       (write (spaces n) port))
 >   )
 >   
 > + ; Concatenate all the arguments and make a string.  Symbols are
 > + ; converted to strings.
 > + (define (concat . sequences)
 > +   (define (sequence->string o) (if (symbol? o) (symbol->string o) o))
 > +   (apply string-append (map sequence->string sequences)))
 > + 
 >   ; Often used idiom.
 >   
 >   (define (string-map fn . args) (apply string-append (apply map (cons fn args))))

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: PATCH: Handle symbols in messages
  2005-01-21  0:26 ` Doug Evans
@ 2005-01-22  2:44   ` Jim Blandy
  2005-01-27 20:38     ` Jim Blandy
  0 siblings, 1 reply; 4+ messages in thread
From: Jim Blandy @ 2005-01-22  2:44 UTC (permalink / raw)
  To: Doug Evans; +Cc: cgen


Doug Evans <dje@transmeta.com> writes:
> fwiw, while string-concat might not clearly specify the operation
> (though I don't have a problem with it), `concat' seems too generic
> (or at least not string-specific enough in the way that the rest of
> the string functions are so named).
> 
> string-map is to map,
> as string-list is to list,
> as string-<mumble> is to concat.
> 
> concat mightn't make sense outside of strings (and thus why have the
> string- prefix ...), but why preclude symbol-concat? (etc.)
> 
> How about string-concat?

Thanks for picking at this.  I had thought I was naming it after a
Common Lisp function, but now that I look it up I see I was getting my
dialects confused.  (Emacs Lisp has a concat function that does type
conversions on its arguments.)

How about string/symbol-append?  Given that there's no good precedent
for 'concat' after all, and that concat has another meaning in CGEN
.cpu files, and that the distinction between appending and
concatenating is unclear, perhaps we should stick to the verb Scheme
generally uses for this kind of operation, and simply name the types
we're handling.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: PATCH: Handle symbols in messages
  2005-01-22  2:44   ` Jim Blandy
@ 2005-01-27 20:38     ` Jim Blandy
  0 siblings, 0 replies; 4+ messages in thread
From: Jim Blandy @ 2005-01-27 20:38 UTC (permalink / raw)
  To: Doug Evans; +Cc: cgen


Jim Blandy <jimb@redhat.com> writes:
> Doug Evans <dje@transmeta.com> writes:
> > fwiw, while string-concat might not clearly specify the operation
> > (though I don't have a problem with it), `concat' seems too generic
> > (or at least not string-specific enough in the way that the rest of
> > the string functions are so named).
> > 
> > string-map is to map,
> > as string-list is to list,
> > as string-<mumble> is to concat.
> > 
> > concat mightn't make sense outside of strings (and thus why have the
> > string- prefix ...), but why preclude symbol-concat? (etc.)
> > 
> > How about string-concat?
> 
> Thanks for picking at this.  I had thought I was naming it after a
> Common Lisp function, but now that I look it up I see I was getting my
> dialects confused.  (Emacs Lisp has a concat function that does type
> conversions on its arguments.)
> 
> How about string/symbol-append?  Given that there's no good precedent
> for 'concat' after all, and that concat has another meaning in CGEN
> .cpu files, and that the distinction between appending and
> concatenating is unclear, perhaps we should stick to the verb Scheme
> generally uses for this kind of operation, and simply name the types
> we're handling.

There've been no further comments on this, so I've committed the below
on the assumption that it's at least better than the status quo.  But
of course I'm happy to make further changes as people suggest.

2005-01-27  Jim Blandy  <jimb@redhat.com>

	* utils.scm (string/symbol->append): Renamed from 'concat'.
	* opcodes.scm (gen-switch): Use new name.
	* insn.scm (-sub-insn-make!): Same.
	* rtl.scm (rtx-dump): Same.
	* semantics.scm (semantic-compile): Same.

Index: cgen/insn.scm
===================================================================
RCS file: /cvs/src/src/cgen/insn.scm,v
retrieving revision 1.13
diff -c -p -r1.13 insn.scm
*** cgen/insn.scm	20 Jan 2005 22:57:10 -0000	1.13
--- cgen/insn.scm	27 Jan 2005 20:15:24 -0000
***************
*** 271,280 ****
  	 (obj:name insn)
  	 ":"
  	 (string-map (lambda (op newval)
! 		       (concat " "
! 			       (obj:name op)
! 			       "="
! 			       (obj:name newval)))
  		     anyof-operands new-values)
  	 " ...\n")
  
--- 271,280 ----
  	 (obj:name insn)
  	 ":"
  	 (string-map (lambda (op newval)
! 		       (string/symbol-append " "
! 					     (obj:name op)
! 					     "="
! 					     (obj:name newval)))
  		     anyof-operands new-values)
  	 " ...\n")
  
Index: cgen/opcodes.scm
===================================================================
RCS file: /cvs/src/src/cgen/opcodes.scm,v
retrieving revision 1.8
diff -c -p -r1.8 opcodes.scm
*** cgen/opcodes.scm	20 Jan 2005 23:12:50 -0000	1.8
--- cgen/opcodes.scm	27 Jan 2005 20:15:24 -0000
***************
*** 516,522 ****
     (lambda (ops)
       ; OPS is a list of operands with the same name that for whatever reason
       ; were defined separately.
!      (logit 3 (concat "Processing " (obj:str-name (car ops)) " " what " ...\n"))
       (if (= (length ops) 1)
  	 (gen-obj-sanitize
  	  (car ops)
--- 516,523 ----
     (lambda (ops)
       ; OPS is a list of operands with the same name that for whatever reason
       ; were defined separately.
!      (logit 3 (string/symbol-append
! 	       "Processing " (obj:str-name (car ops)) " " what " ...\n"))
       (if (= (length ops) 1)
  	 (gen-obj-sanitize
  	  (car ops)
Index: cgen/rtl.scm
===================================================================
RCS file: /cvs/src/src/cgen/rtl.scm,v
retrieving revision 1.8
diff -c -p -r1.8 rtl.scm
*** cgen/rtl.scm	20 Jan 2005 22:57:10 -0000	1.8
--- cgen/rtl.scm	27 Jan 2005 20:15:24 -0000
***************
*** 786,796 ****
  
  (define (rtx-dump rtx)
    (cond ((list? rtx) (map rtx-dump rtx))
! 	((object? rtx) (concat "#<object "
! 			       (object-class-name rtx)
! 			       " "
! 			       (obj:name rtx)
! 			       ">"))
  	(else rtx))
  )
  
--- 786,796 ----
  
  (define (rtx-dump rtx)
    (cond ((list? rtx) (map rtx-dump rtx))
! 	((object? rtx) (string/symbol-append "#<object "
! 					     (object-class-name rtx)
! 					     " "
! 					     (obj:name rtx)
! 					     ">"))
  	(else rtx))
  )
  
Index: cgen/semantics.scm
===================================================================
RCS file: /cvs/src/src/cgen/semantics.scm,v
retrieving revision 1.6
diff -c -p -r1.6 semantics.scm
*** cgen/semantics.scm	20 Jan 2005 22:57:10 -0000	1.6
--- cgen/semantics.scm	27 Jan 2005 20:15:25 -0000
***************
*** 798,808 ****
  		  sorted-outs out-op-nums)
  
  	(let ((dump (lambda (op)
! 		      (concat "  "
! 			      (obj:name op)
! 			      " "
! 			      (number->string (op:num op))
! 			      "\n"))))
  	  (logit 4
  		 "Input operands:\n"
  		 (map dump sorted-ins)
--- 798,808 ----
  		  sorted-outs out-op-nums)
  
  	(let ((dump (lambda (op)
! 		      (string/symbol-append "  "
! 					    (obj:name op)
! 					    " "
! 					    (number->string (op:num op))
! 					    "\n"))))
  	  (logit 4
  		 "Input operands:\n"
  		 (map dump sorted-ins)
Index: cgen/utils.scm
===================================================================
RCS file: /cvs/src/src/cgen/utils.scm,v
retrieving revision 1.14
diff -c -p -r1.14 utils.scm
*** cgen/utils.scm	20 Jan 2005 22:57:10 -0000	1.14
--- cgen/utils.scm	27 Jan 2005 20:15:25 -0000
***************
*** 87,93 ****
  
  ; Concatenate all the arguments and make a string.  Symbols are
  ; converted to strings.
! (define (concat . sequences)
    (define (sequence->string o) (if (symbol? o) (symbol->string o) o))
    (apply string-append (map sequence->string sequences)))
  
--- 87,93 ----
  
  ; Concatenate all the arguments and make a string.  Symbols are
  ; converted to strings.
! (define (string/symbol-append . sequences)
    (define (sequence->string o) (if (symbol? o) (symbol->string o) o))
    (apply string-append (map sequence->string sequences)))
  

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-01-27 20:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-20 22:59 PATCH: Handle symbols in messages Jim Blandy
2005-01-21  0:26 ` Doug Evans
2005-01-22  2:44   ` Jim Blandy
2005-01-27 20:38     ` Jim Blandy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).