I often find myself wanting to print out (usually for debugging purposes) a structure such as a hash table, i.e. writing `print (city_table)’ and getting a reasonable default view such as list of [value, key] pairs:
[“PARIS”, ‘P’] [“CHICAGO”, ‘C’] [“RIGA”, ‘R’] …
print (x) actually displays x.out where `out’ is a STRING-returning function from class ANY which by default yields an internal format but may be redefined in any class. Such redefinitions exist for basic types INTEGER etc., but no one has ever taken the trouble to write some for for EiffelBase data structure classes. (I am not a Gobo user but a quick look also did not reveal such redefinitions – maybe there is something else that I missed.) What I would find useful is to the kind of above simple representation, directly adapted to the semantics of each kind of data structure as understood by their users. If I have a hash table this is how I would like to see it in the debugger, not the internal representation. (Admittedly, EiffelStudio gurus tell me they don’t care, and can read that representation.) There is a class DEBUG_OUTPUT but its idea has not been exploited much either so far.
Building such a readable representation for the major data structures in EiffelBase does not seem to be a very large effort. We are talking about maybe a dozen cases. If anyone is willing to help I’d be happy to coordinate the effort. (Let me use this opportunity to apologize for not pushing more yet on the LLVM/WebAssembly idea discussed some time ago. It is a much more ambitious project and not enough people were willing to commit the necessary resources, which is understandable. This one is much smaller.)
Messing up right away with ANY or a core library class such as DEBUG_OUTPUT is not a good idea so as a first step I would propose a visitor-style approach, talking “about” structures from the outside rather than working inside of them. In other words, a solution such as
{RENDERER}.output (my_structure)
yielding a STRING representing my_structure if RENDERER knows about its type, otherwise defaulting to my_structure.out. In other words, output in RENDERER (ms) would be written as something like
if {ARRAY [ANY]] ms as a then
... nice representation of array `a’...
elseif {HASH_TABLE [ANY, COMPARABLE] ms as h the
... nice representation of hash table h
...
else ms.out end
(This is a first cut, there may be a more clever way.) Of course this scheme does not look like the ideal OO structure but it is what you have to write if you want an outside, visitor-style mechanism that applies to various types. It has the dual advantage of allowing several renderers (inheriting from a general RENDERER class providing defaults). Once we are happy with one of them, we can always lobby for inclusion of the best solutions as redefinitions of `out’ in EiffelBase classes, restoring a textbook OO approach.
In my opinion the representations, as with the hash table representation above, should be terse and as much as possible use symbols rather than words, to avoid having to worry about translation into various human languages.
I think having such code would be useful. This is not a major endeavor but it will proceed faster if a few people help. This would mean taking up a couple of example structures, telling me about it, and within a month or so (let’s say August 31) sending me the corresponding branches of the above conditional, with examples and test results. I am happy to do HASH_TABLE and provide it as a guideline for others.
Thanks,
-- BM
That answer was fast. I will write the HASH_TABLE version tomorrow.
-- BM
--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
Visit this group at https://groups.google.com/group/eiffel-users.
For more options, visit https://groups.google.com/d/optout.
--
Looks good (sorry, I got sidetracked) but please observe Eiffel style rules: meaningful feature names (column_count, not ncols), spaces before opening parentheses, “description” note at head of class, and never even think of writing a feature without a header comment (which, for a routine, must list every argument, e.g. – Print `n’ according to `format’).
-- BM
From: eiffel...@googlegroups.com [mailto:eiffel...@googlegroups.com] On Behalf Of williams Lima
Sent: Sunday, 19 August, 2018 18:40
To: Eiffel Users <eiffel...@googlegroups.com>
Great, sorry for being fussy, but you write you are a beginner and not everyone realizes right away that style rules are an integral part of the Eiffel approach. Note that to change feature names you can use the refactoring tool (Context menu on feature -> Refactor -> Rename) – this will update the calls as well.
> email to eiffel-users+unsubscribe@googlegroups.com.
Larry Rix <lar...@moonshotsoftware.com>:
Larry Rix <lar...@moonshotsoftware.com>:
--
On Aug 22, 2018, at 6:41 PM, Larry Rix <lar...@moonshotsoftware.com> wrote:The library on GitHub has been updated with more notes, comments, tests, helper, and convenience features.
--
I am happy that this little suggestion of mine met with such energy – and happy too to let it proceed on its own, obviously much further than what I had in mind (a class or a few). Thanks!
--- BMWith best regards,
-- Bertrand Meyer
--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
Larry Rix <lar...@moonshotsoftware.com>:
--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users+unsubscribe@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users+unsubscribe@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users+unsubscribe@googlegroups.com.
Larry Rix <lar...@moonshotsoftware.com>:
--
--
--
Happy to do so! Thanks to Alex for pressing the matter once again to get me to look more closely.
--
Larry,just for a style matter. Is it possible to place the if for ITERABLE as the last one!?I would like to have all 'basic' cases treated first and leave the recursive call to be the last.Williams
On Mon, Aug 27, 2018 at 9:14 AM, Larry Rix <lar...@moonshotsoftware.com> wrote:
Happy to do so! Thanks to Alex for pressing the matter once again to get me to look more closely.
--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
--
If you want to do some work on it we can communicate directly by email in orderto not pollute the forum. And of course make some updates here when convenient.