Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.2 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Perl Modules

    Decl 0.11

    Download button

    No screenshots available
    Downloads: 100  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Michael Roberts | More programs
    Perl Artistic License / FREE
    October 22nd, 2011, 11:10 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    Decl description

    Provides a declarative framework for Perl

    Decl is a Perl module, a framework for writing Perl code in a declarative manner. What that means right now is that instead of seeing a script as a series of actions to be carried out, you can view the script as a set of objects to be instantiated, then invoked. The syntax for building these objects is intended to be concise and flexible, mostly staying out of your way. Perl code is used to declare actions to be taken once the structure is built, as well as any actions to be taken interactively as the script runs.

    The original motivation for designing this framework was to provide a more rational way of defining a Wx user interface. As it is, the data structures making up a Wx GUI are built with painstakingly detailed (and boring) imperative code. There are XML-based GUI specification frameworks, but I wanted to write my own that wasn't XML-based because I hate typing XML even more than I hate writing setup code.

    Back when I did a lot of GUI work, I'd usually write some pseudocode to describe parts of the UI, then translate it into code by hand. So this year, while noodling around about some tools I'd find useful in my translation business, I thought, well, why not just write a class to interpret that pseudocode description directly?

    Once I started getting into that in earnest, I realized that the Wx-specific functionality could be spun out into an application-specific (in my new parlance, a "semantic") domain, leaving a core set of functionality that was a general declarative framework. I then realized that the same framework could easily be used to work with domains other than Wx GUIs, such as building PDFs, building Flash applications, doing things with Word documents... All kinds of things. All of those things are currently in pieces on the workbench - except for the Word module, which is ready, if not for prime time, then at least for deep cable midnight airing.

    Here's a GUI example using something like the Wx domain. This is a pretty simple example, but it gives you a taste of what I'm talking about. Since Decl runs as a source filter, the example below is a working Perl script that replaces roughly 80 lines of the Wx example code it was adapted from. And yes, it runs in my test suite right now.

       use Wx::Declarative;
      
       dialog (xsize=250, ysize=110) "Wx::Declarative dialog sample"
          field celsius (size=100, x=20, y=20) "0"
          button celsius (x=130, y=20) "Celsius" { $^fahrenheit = ($^celsius / 100.0) * 180 + 32; }
          field fahrenheit (size=100, x=20, y=50) "32"
          button fahrenheit (x=130, y=50) "Fahrenheit" { $^celsius = (($^fahrenheit - 32) / 180.0) * 100; }


    The main things to look at are as follows: first, yes - syntactically significant indentation. I know it's suspiciously Pythonic, I know all the arguments citing the danger of getting things to line up, and I don't care; this is the way I have always written my pseudocode, and odds are you're no different and you know it. If it makes you feel better, the indentation detection algorithm is pretty flexible, and Perl code within curly braces is exempt from indentation significance. (Not that this example has any multiline code, but you see what I mean.)

    Second, fields are declared here and their content is exposed as magic variables in the code snippets. You will immediately see that code embedded in a declarative structure goes through a modification pass before being eval'd into a sub. So there is a possibility that I have screwed that modification pass up. I don't have an answer for this right now; the point is quick and easy, not perfection (yet). Caveat emptor. It's still a neat feature.

    There is a standard parser and standard data structure available for tags to use if it suits your purpose - but there's no mandate to use them, and the parser tools are open for use. They're still a little raw, but pretty powerful.

    A declarative object can report its own source code, and that source code can compile into an equivalent declarative object. This means that dynamically constructed objects or applications can be written out as executable code, and code has introspective capability while in the loaded state. Decl also has a macro system that allows the construction of code during the build phase; a macro always dumps as its source, not the result of the expansion, so you can capture dynamic behavior that runs dynamically every time.


    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    declarative framework | Perl module | Perl | declarative | framework

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM