unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* [PATCH] Source properties on arbitrary non-immediate values
@ 2005-10-07 12:23 Ludovic Courtès
  2005-10-07 20:47 ` Kevin Ryde
  0 siblings, 1 reply; 13+ messages in thread
From: Ludovic Courtès @ 2005-10-07 12:23 UTC (permalink / raw)


Hello,

Does anyone know the rationale for allowing to attach source properties
_only_ to pairs?

Since I couldn't think of any compelling reason, I tried to remove this
limitation, and still I can't see any problem.  :-)  The patch below
allows to do things like this:

  guile> (define x 'a-symbol)
  guile> (set-source-properties! x '((a . 2)))
  ((a . 2))
  guile> (source-properties x)
  ((a . 2))
  guile> (define s "a string")
  guile> (set-source-properties! s '((line . 12)))
  ((line . 12))
  guile> (source-property s 'line)
  12

Thanks,
Ludovic.


2005-10-07  Ludovic Courtès  <ludovic.courtes@laas.fr>

	* srcprop.c (source-properties):  Accept non-pair objects.
	(set-source-properties!):  Likewise.
	(source-property):  Likewise.
	(set-source-property!):  Likewise.


\f
--- orig/libguile/srcprop.c
+++ mod/libguile/srcprop.c
@@ -157,8 +157,7 @@
   SCM_VALIDATE_NIM (1, obj);
   if (SCM_MEMOIZEDP (obj))
     obj = SCM_MEMOIZED_EXP (obj);
-  else if (!scm_is_pair (obj))
-    SCM_WRONG_TYPE_ARG (1, obj);
+
   p = scm_hashq_ref (scm_source_whash, obj, SCM_EOL);
   if (SRCPROPSP (p))
     return scm_srcprops_to_plist (p);
@@ -180,8 +179,7 @@
   SCM_VALIDATE_NIM (1, obj);
   if (SCM_MEMOIZEDP (obj))
     obj = SCM_MEMOIZED_EXP (obj);
-  else if (!scm_is_pair (obj))
-    SCM_WRONG_TYPE_ARG(1, obj);
+
   handle = scm_hashq_create_handle_x (scm_source_whash, obj, plist);
   SCM_SETCDR (handle, plist);
   return plist;
@@ -198,8 +196,7 @@
   SCM_VALIDATE_NIM (1, obj);
   if (SCM_MEMOIZEDP (obj))
     obj = SCM_MEMOIZED_EXP (obj);
-  else if (!scm_is_pair (obj))
-    SCM_WRONG_TYPE_ARG (1, obj);
+
   p = scm_hashq_ref (scm_source_whash, obj, SCM_EOL);
   if (!SRCPROPSP (p))
     goto plist;
@@ -230,8 +227,7 @@
   SCM_VALIDATE_NIM (1, obj);
   if (SCM_MEMOIZEDP (obj))
     obj = SCM_MEMOIZED_EXP (obj);
-  else if (!scm_is_pair (obj))
-    SCM_WRONG_TYPE_ARG (1, obj);
+
   h = scm_whash_get_handle (scm_source_whash, obj);
   if (SCM_WHASHFOUNDP (h))
     p = SCM_WHASHREF (scm_source_whash, h);



_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


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

end of thread, other threads:[~2005-10-17  8:08 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-07 12:23 [PATCH] Source properties on arbitrary non-immediate values Ludovic Courtès
2005-10-07 20:47 ` Kevin Ryde
2005-10-08 18:01   ` Neil Jerram
2005-10-10 12:10     ` Ludovic Courtès
2005-10-10 16:43       ` Neil Jerram
2005-10-11  8:53         ` Ludovic Courtès
2005-10-11 19:24           ` Neil Jerram
2005-10-12  8:42             ` Ludovic Courtès
2005-10-15 17:59               ` Neil Jerram
2005-10-15 18:36                 ` Neil Jerram
2005-10-17  8:08                   ` Ludovic Courtès
2005-10-10 21:24       ` Kevin Ryde
2005-10-11  8:43         ` Ludovic Courtès

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).