forum-msg-id-129833-edit

Original date:2016-06-01 08:39:36 Edited by: petelomax Subject: Re: tutorial Ruby to Euphoria -- Example on Wiki

_tom said...

My tutorial

Some quick comments and ideas, several of which may be nonsense:

I took exception to the use of "database". I would replace that word with "definitions" throughout.
Replace file_type()=1 with file_type()=FILETYPE_FILE
When I saw managers[i][1], my immediate thought was to replace the 1 with a more descriptive constant/enum declared in with the Package Manager Definitions...
Looking at options and the definitions, there is an anonymous and invisible correspondence which rang a few alarm bells.
It is a bit like a police raid on a seedy motel: look round and half the shirt buttons are done up all wrong.
First off, I'd move options in with the definitions.
Then I'd seriously consider (it might not work, I haven't thought it through) making it a "help" entry in the main table[1] (skipped in the locate_file scan).
Then I'd add an enum and break all the declarations up into discrete assignments based on those symbolic constants, eg

managers[K_HELP][K_DESC] = "help" 
managers[K_KELP][K_COMMANDS][K_REINSTALL] = {"ri", "ri", "reinstall"} 
managers[K_DNF][K_DESC] = "dnf" 
managers[K_DNF][K_COMMANDS][K_REINSTALL] = "dnf reinstall" 

Of course much more typing, but hopefully a less brittle design, with far less of that misaligned shirt buttons thing.
Also, I'd move which() into the definitions file as well, and I'd ask whether all the data in PkgMgrs.e should be private, we only need an index outside it?
I also spotted options[i][2..$] used a couple of times, and decided that should really be a [named] subsequence.

I think one of the big differences here between Ruby and Euphoria is that given a "def dnf()" then (I assume) send("dnf") [yes, a text string] invokes that routine. Obviously that is not really any different to routine_id().

HTH, Pete

Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu