Article View: comp.lang.misc
Article #953Re: trivial portability (was: Relationship between C and C++)
From: Skef Wholey
Date: Thu, 22 Mar 1990 23:12
Date: Thu, 22 Mar 1990 23:12
40 lines
2423 bytes
2423 bytes
Date: 22 Mar 90 21:47:20 GMT
From: gumby@Gang-of-Four.Stanford.EDU (David Vinayak Wallace)
Date: 22 Mar 90 18:55:53 GMT
From: adrian@mti.mti.com (Adrian McCarthy)
Exercise for the reader: write a *portable* program in any language which
takes a file name as its parameter and returns the modification or creation
date and time of that file. Don't use any conditional compilation.
Took longer to trim your message above than it took me to write the
code below (in common lisp):
(defun demo ()
(format "~&Enter pathname to examine: ")
(let ((pathname (pathname (readline))))
(multiple-value-bind (second minute hour day month year)
(decode-universal-time (file-write-date pathname))
(format "The file was written by ~a; on ~D-~D-~D at ~D:~D:~D"
(file-author pathname) day month year hour minute second))))
Wow, you sure can write buggy code quickly! I don't mean to be pedantic
or snotty or anything -- I just think it's kind of funny that in the
six-line body you've got three bugs. Both calls to Format need a stream
argument, and the Common Lisp function is called Read-Line, not
Readline. But, with these things fixed, it does indeed do the job. It
was kind of neat to cut the code from rn running in an xterm and paste
it right into my Lisp editor. I bet I got the error messages even
faster than you generated the bugs!
Also, you're not quite following the spec as written (the file name should
be an argument), but I would be picking nits it I picked on that.
(For a good time, look up "Teenage Mutant Ninja Turtles" (or even
"Turtles, Teenage Mutant Ninja") in the index to CLtL 2nd edition. Also
look at the entry for "hyperspace." You must admit the index is an
improvement over the first edition....)
--Skef
Technical Details
Message-ID:
<8562@pt.cs.cmu.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!tut.cis.ohio-state.edu!pt.cs.cmu.edu!skef.slisp.cs.cmu.edu!skefReferences:
<EGB2327xds13@ficc.uu.net> <8432@hubcap.clemson.edu> <GUMBY.90Mar22134720@Gang-of-Four.Stanford.EDU>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!tut.cis.ohio-state.edu!pt.cs.cmu.edu!skef.slisp.cs.cmu.edu!skef From: skef@skef.slisp.cs.cmu.edu (Skef Wholey) Newsgroups: comp.lang.misc Subject: Re: trivial portability (was: Relationship between C and C++) Keywords: portability myth lisp bugs Message-ID: <8562@pt.cs.cmu.edu> Date: 22 Mar 90 23:12:37 GMT References: <EGB2327xds13@ficc.uu.net> <8432@hubcap.clemson.edu> <GUMBY.90Mar22134720@Gang-of-Four.Stanford.EDU> Organization: Carnegie-Mellon University, CS/RI Lines: 40