This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

About the guile module system



Hi,

maybe someone could answer me the following questions

* what are ssymbols good for.  As far as I can see they make programming
  much more complicated and slow down the evaluator (strhash has to be called
  over and over again).

* when a symbol is defined (in `scm_sym2vcell') why is it removed from 
  weak_symhash?  I think this is wrong since two symbols with the same
  name should *always* be equal!  

* what is a "symbol listed in no obarray"?  Either a symbol is a
  symbol and thus interned scm_weak_symhash or it doesn't exist at
  all, no?



For example

(module '(home users j jost mod1))
(export '(ex1 ex2))
(protect '(pr1 pr2))

(define pr1 1)
...

(module '(home users j jost mod2))
(export '(ex3 ex4 j))
(protect '(pr3 pr4))

(define j 11)
...

(module-open-all '(home users j jost)) ; imports mod1 and mod2

>From the symlist '(home users j jost) one has to create two new
symbols: 'home/users/j/jost and 'mod1.  Symbol 'home/users/j/jost is a
directory (aka package) and interned in package-hash.

The problem is the symbol `j': Is it a ssymbol or a msymbol?
I don't think it is a good idea to artificially divide symbols into two
categories so I think it is best to remove ssymbols from guile completely.

The other reason why I want to remove ssymbols is that they may save some
bytes but they make symbol lookup slow:


[...]

				/* from useslist? */
	  obarray = SCM_MODULE_FOREIGN_OBARRAY (mod);
	  if (SCM_NIMP (obarray) && (modify != -1) )
	    {
	      vcell = scm_sym2vcell0 (sym, obarray, scm_hash);
	      if (SCM_NIMP (vcell))
		{		
		  if (modify == 1) /* copy symbol to current obarray */
		    {
		      vcell = scm_wta (sym, 
				       "can't shadow foreign symbol. ", "");
		    }
		  else 
		    {
		      mod = SCM_CDR (vcell);

		      if (found_in_module) /* if msymbol */
			*found_in_module = mod;

		      obarray = SCM_MODULE_OBARRAY (mod);
		      vcell = scm_sym2vcell0 (sym, obarray, scm_hash);

		      if (SCM_IMP (vcell)) 
			abort();
		    }
		  SCM_ALLOW_INTS;
		  return vcell;
		}
	    }
	}
				/* Always look in scm_symhash */
      obarray = scm_symhash;
      vcell = scm_sym2vcell0 (sym, obarray, scm_hash);
      if (SCM_NIMP (vcell))
	{
	  SCM_ALLOW_INTS;
	  return vcell;
	}

 	


Jost