Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I'd have to say yes. D has hashes, which is great, but the first thing I wanted when I started coding in D was a generalised structure for holding configuration and command line parameters. Something akin to Perl's A hash is the perfect structure for this, but hashes in D have typed values. They can be anything, but each hash can only contain values of the specified type. That is dashed inconvenient when one is used to having polymorphic hashes.

So about the first thing I did was to define polymorphic hash class that used void* to bypass the type checking:

typedef void*[ char[] ] Config;

Of course, the D guru's would view this as "typical of someone coming from 'scripting' languages", and could be viewed as writing D with a Perlish accent.

One day I'll get around to re-writing it using templates and mixins to do away with all the explicit casting, but for now, almost every non-trivial D program I write uses that first attempt to handle command line arguments and configuration. I did add persistance to the class so that I avoid having to specify every parameter every time--it just remembers the values from last time I specified it.

That also allows a degree of self-configuration. Each run of a program can remember things like the number of instances of a particular class that it used this time and average that with the number record in it's configuration. Then the next time the program runs, it can pre-allocate space for this number of instances when the class initialises which avoids a bit of thrashing and GC runs for highly dynamic classes.

Using Perl for an extended period of time has certainly affected the way I code in a whole range of ways. For a while now I have been looking around at the features and facilities of several other languages and comparing both the features and implementations. Even when other languages have equal or greater feature sets, Perl always comes out on top for ease of use and the way it manages to blend those features together into the langauge. Perl 5 has lots of weird nooks and crannies and inconsistencies, but it still manages to blend it's features better than most other languages I've looked at.

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco.
Rule 1 has a caveat! -- Who broke the cabal?

In reply to Re^4: pissed off about functional programming by BrowserUk
in thread pissed off about functional programming by mstone

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others scrutinizing the Monastery: (4)
    As of 2020-08-11 22:48 GMT
    Find Nodes?
      Voting Booth?
      Which rocket would you take to Mars?

      Results (63 votes). Check out past polls.