- From: Sean B. Palmer <sean+cwm@infomesh.net>
- Date: Mon, 09 Aug 2004 19:17:10 +0100
- To: public-cwm-bugs@w3.org
Daniel Biddle [+BCC] has come up with an excellent suggestion [1], which I've augmented marginally with his agreement, as to a replacement for the os:argv builtin property. The localname "argv" is a counter-intuitive misnomer anyway given that the property really means "indexOfArg", but the suggestion is for os:Argv to be a list of the arguments (since it is a list anyway), and to instead devise a powerful Lisp-esque builtins module for CWM. CWM would therefore, instead of generating {"1" os:argv "bar". "2" os:argv "baz"} using the example in [2], have to generate {os:Argv rdf:first "bar"; rdf:rest ("2")}. The N3 to get command line arguments would become, for example: (os:Argv "1") list:get ?arg . There are many benefits. For example, this would also enable one to get the argument count simply by doing something such as: os:Argv list:length ?argc . Or to get a slice of the argv list using: (os:Argv "3" "7") list:slice ?someArgs . It would also maintain consistency with the majority of programming language libraries throughout time that make the arguments passed on the command line available in an array. The os:argv builtin could become merely sugar for {(os:Argv ?subj) list:index ?objt}, but I suggest that it be deprecated in favour of an os:indexOfArg property, or deprecated entirely. The rationale--almost enough to consider this a bug, not an RFE--is that os:argv is extremely difficult to learn to use for newcomers to the language, and has no particular mnemonic for remembering it. I implemented a list builtins module for CWM called "lexp" ([3], [4]) back in 2002, but you'll probably want to use a module with a different specification. If one of you (DanC, Sir. timbl, or yosi) were to document the properties you'd like, and suggest a namespace, I'd be happy to implement the module--it should be trivial anyway. As a real world example of how os:Argv would change things, here's a redrafting of a line from the Trust [5] document. The original: "1"!os:argv!os:baseAbsolute^log:uri log:semantics :F. becomes: (os:Argv "1").list:get.os:baseAbsolute^log:uri log:semantics :F . (don't forget to change the "!" forward traversals to "." if that's what's been decided upon) which I don't think is too heavy a burden to bear given the benefits, and I hope you agree! Many thanks, [1] http://swhack.com/logs/2004-08-09#T17-20-13 [2] http://www.w3.org/2000/10/swap/os [3] http://lists.w3.org/Archives/Public/www-archive/2002Mar/0002 [4] lexp.py the module -> http://lists.w3.org/Archives/Public/www-archive/2002Mar/att-0004/lexp.py [5] http://www.w3.org/2000/10/swap/doc/Trust -- Sean B. Palmer, http://inamidst.com/
Received on Monday, 9 August 2004 18:17:41 UTC