'''pseud(o)-''' ''comb form'' not genuine, false or pretended ---- Generally it means some code-like notation, perhaps with real code embedded, which cannot be directly executed because the machine needs detail which has been omitted. Sometimes the detail is merely syntax we couldn't be bothered with. Sometimes it is stuff we didn't yet know how to do. Arguably you need much less pseudocode in languages like Smalltalk which don't insist on spurious detail. That is, you can push the omitted detail down into methods which can be filled in later. Then the original pseudocode will execute fine. ---- Can you give some smalltalk examples? I know how it works in Python.... ---- ''Arguably''? Uncontestably, I'd tend to believe. I don't know about smalltalk, but the way it works in Lisp is that you write the pseudocode, replace space characters by dashes, then put parens around each line. Well, more or less. All you need to do then is write functions/methods to perform each line and macros to implement any new control structures you just invented. Trivial example: before do query "select name, rank, number from foo where bar" for each row soldier=get soldier(name) soldier.number=number After (with-sql-query (rows "select name, rank, number from foo where bar") (dolist (r rows) (let ((soldier (get-soldier name))) (setf (soldier-number soldier) number)))) Assuming a suitable definition (elsewhere) of the SOLDIER class and the WITH-SQL-QUERY macro, that could be valid Lisp. Isn't this what TopDownProgramming is all about? :-) It would be rather odd Lisp, for two reasons. (1) I'd expect there to be a macro that combines WITH-SQL-QUERY and DOLIST. It probably wouldn't actually cons up the list at all. (2) To arrange for NAME to be bound, your macro is having to parse that string, which feels rather evil. How about the following? (for-sql-query-rows (rows (((name rank number) foo)) (bar)) (let ((soldier (get-soldier name))) (setf (soldier-number soldier) number))) The rationale behind the paren-heavy syntax on the first line is: you have a list of (fields table-name) items, and then a list of things to feed to WHERE. In this case we're only looking at a single table. This may possibly make no sense; my SQL is very rusty. An alternative approach, which maybe I like better, is to pass both the SQL query string (as a string) and a list of field names: after all, there's no reason why the variable names have to match SQL's names for the fields. By the way, you haven't used the rank at all. :-) -- GarethMcCaughan '''Hmm.''' Isn't one of the reasons for using pseudocode that it is readable like natural language? If that is one of the goals then I propose that Lisp isn't a good alternative. Oddly enough, my pseudocode has always looked like procedural languages even way back before I knew what I was doing. My pseudocode description nowadays still has that flavor to it. For one thing, I can show the pseudocode to a non-technical person and it reads like a procedural instruction sheet, exactly the effect I want. -- MartySchrader For what it's worth, I agree. Lisp is a great language, but it's not my idea of pseudocode. -- GarethMcCaughan ---- For some reason, when I try to write PseudoCode, it always ends up looking like Python. Strange. ''That's funny, I remember a Pickover book where several people I showed it to thought the examples were in pseudo-code, but they were actually in RexxLanguage. It helps that Rexx is ridiculously high level and also has very little punctuation.'' ---- Pseudocode is even easier if you use LiterateProgramming. In fact, when I read Michael Dyer's CleanroomSoftwareEngineering, my immediate reaction to his design notation was "Hey, that's just LiterateProgramming with NoWeb, I can write that design literately and it can be run as-is." So I did. -- BillTrost I seem to remember reading about some competition where the Haskell (or maybe OCaml) entry was rejected because the judges thought it was just pseudocode. When it was demonstrated to run they rejected it because it used "too many tricks". I'm not sure what happened after that, but the Haskell (or other) people were pretty hacked off as I recall. Can anyone find a reference for this? ''I've never seen HaskellLanguage code that was so clear as to be mistaken for PseudoCode. Examples?'' ---- Has anyone considered defining a PseudoCode specification language? A sort of AntiUml to save us from all that pointing, clicking and daft dialog boxes. ''PythonLanguage?'' ---- Contributors: PatrikPersson, BillTrost, GarethMcCaughan, MartySchrader CategoryProgrammingLanguage