home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / prolog / 1549 < prev    next >
Encoding:
Text File  |  1992-08-18  |  1.8 KB  |  52 lines

  1. Newsgroups: comp.lang.prolog
  2. Path: sparky!uunet!usc!sol.ctr.columbia.edu!destroyer!ubc-cs!fornax!gregory
  3. From: gregory@cs.sfu.ca (Gregory Sidebottom)
  4. Subject: Re: SICStus Prolog singleton warnings slow down while consulting a file
  5. In-Reply-To: rah@ybrig.zurich.ibm.com's message of Mon, 17 Aug 92 17:21:26 GMT
  6. Message-ID: <1992Aug17.210426.14213@cs.sfu.ca>
  7. Organization: CSS, Simon Fraser University, Burnaby, B.C., Canada
  8. References: <1992Aug17.172126.19111@watson.ibm.com>
  9. Date: Mon, 17 Aug 1992 21:04:26 GMT
  10. Lines: 40
  11.  
  12. In article <1992Aug17.172126.19111@watson.ibm.com> rah@ybrig.zurich.ibm.com (Ralf Hauser) writes:
  13.  
  14.    While porting a big C-Prolog program to SICStus Prolog, I encounter
  15.    the following problem:
  16.  
  17.    To make the program readable, I gave a name to many variables which
  18.    are essentially _ (don't care). 
  19.  
  20. That is a good thing to do.
  21.  
  22.    When (re)consulting my program,
  23.    every time many screens of such warnings are produced which
  24.    slow down the testing and programming annoyingly.
  25.  
  26.    Does anybody know, how to suppress these warnings or to
  27.    maintain the same expressivity of code without creating those
  28.    "singleton variables".
  29.  
  30. Try starting your singlton variables with the underscore symbol.  This
  31. tells the compiler that you know it's a singlton variable, even though
  32. you want to give it a meaningful name.  So you can write:
  33.  
  34. p(_SomethingMeaningful).
  35.  
  36. and not get a warning in Sicstus.  But note that variables beginning
  37. with an underscore are not anonymous--the two variable symbols in:
  38.  
  39. p(_X) :- q(_X).
  40.  
  41. denote the same variable.  Whereas in:
  42.  
  43. p(_) :- q(_).
  44.  
  45. the underscores denote two distinct variables.
  46.  
  47. Greg
  48. -- 
  49. Greg Sidebottom,                                      | There's not a word that
  50. Expert Systems Laboratory, Centre for Systems Science | goes here that rhymes
  51. Simon Fraser University, Burnaby BC V5A 1S6, Canada   | with anything. -CVB
  52.