simonodell has asked for the wisdom of the Perl Monks concerning the following question:
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: more bracket chaos
by mr_mischief (Monsignor) on Aug 30, 2007 at 16:06 UTC | |
It's important to know that if you reimplement a publicly available solution which has lots of support from the community, you are taking a pass on all of that support. The downside of reinventing wheels when you don't know what's out there is that you could be duplicating work and doing a worse job of it. Even if you duplicate what you know about, you're still doing things a new and different way that people will be slower to help you develop. That's because they're all busy enough learning, using, and helping people with the existing, popular tool sets. If your solution is good enough that it overcomes these obstacles, that's great. Expecting it to be warmly accepted over and above the established alternatives without showing people why it's better is a bit presumptuous. If you can show us how great your system is, but it takes lots of examples, then perhaps a tutorial, Perl.com or use.Perl.org article, a book, or a website showing us how to use it and why it is worth learning despite extant alternatives, then you'd probably get much better traction. This may very well fit your needs better than any of the existing solutions. You've not said why it does, though. You also seem to be implying it will meet the needs of others better than the existing solutions, and again we don't see why. As a disclaimer, I'll say that I, personally, use a home-grown application framework quite regularly. I don't ask other people to help with it or to learn it in favor of more general and better documented frameworks, though. There are reasons to use standard tools, and there are at times exceptions. There is never an exception without some trade-offs, though. | [reply] |
by simonodell (Acolyte) on Aug 30, 2007 at 16:54 UTC | |
I came to perl monks a few months back and found out a lot, but still none of the existing modules appear to do what i was working on, and it looked like a huge task to learn what to me was a whole new way of doing things. im still struggling with OO, it just wasnt on the syllabus when i did college, and as a result my code looks a lot like the ansi C i was trained to write all them years ago. | [reply] |
|
Re: more bracket chaos
by Anno (Deacon) on Aug 30, 2007 at 16:29 UTC | |
Throughout your writeup you are trying to anticipate critical thoughts your readers might have, putting them in their mouth as it were, so as to obviate the need for actually thinking them. The very subject is an example, and it goes on with
| [reply] |
by simonodell (Acolyte) on Aug 30, 2007 at 16:59 UTC | |
this time im back just to give away my idea, i dont want anything back, im just a few weeks away from launching a full ecommerce site using this, and i know just how off the wall it is so im presenting as such, an oddity, perhaps if the peer review finally says so, an absurdity... either way these results are much better than last time :) | [reply] |
|
Re: more bracket chaos
by Zen (Deacon) on Aug 30, 2007 at 14:03 UTC | |
a) If it's a question, it's buried beneath the hype b) If it has anything to do with perl (besides saying 'CGI,' which is available in other languages, too), I can't tell. Try posting in the cool uses for perl section. | [reply] |
|
Re: more bracket chaos
by Jenda (Abbot) on Aug 31, 2007 at 00:09 UTC | |
Your solution doesn't scale. Suppose you've decided to use the first solution and then later you need to enclose this in yet another case statement. OK, you can go and change all those <> to square brackets and normal brackets to <>. And what do you do next time? If the two case statements end up in yet another or in an if? I think you need to find a different way to do this. Even if it means that the parser has to know these few statements as <if>, <case> and <for>. Or maybe it would be best to parse the file as an ordinary XML and then process it FROM THE ROOT up, always parsing and processing the values of all attributes the same way the whole file is and then if there is a plugin specified for the tag pass both the already processed attributes and not processed content to the plugin and let it decide whether to call the processing for the subtags and then do something with the results or do something with the subtags and then call the recursive processing for the subtags. If there is no plugin, then all the subtags will be processed in order. I've actually tried to write such a beast ... and found out that I can't write <tag attr="xxx <othertag/> yyy"/> so I decided to change < to { and > to } within the attributes --> <tag attr="xxx {othertag/} yyy"/>. Here's the result:
The plugins get as their only parameter a reference to a hash containing the attributes, subtags and content of the tag. There are three kinds of keys in the hash:
Not sure it will work for you, but it was an interesting exercise. | [reply] [d/l] [select] |
by simonodell (Acolyte) on Aug 31, 2007 at 21:05 UTC | |
my processor works with the examples I gave and more complex code. within a recursive structure where all the brackets are of the same bracket type my system allows virtually unlimited recursion, however when mixtures of brackets are used, it does as you pointed out have a limitation. my solution to this, was to make the insertfile routine restart the parser, and thus through multiple files you can indefinitely continue to use the 3 bracket structure. of course with anything very complicated this would become cumbersome having lots of sub files to deal with as a result i tend to try and be as abstract as possible within the xml-esque control file, and have the plugins do the donkey work. this also leaves the top control file being very close to an english description of what the plugins are doing below, such as <trylogin> or <uploadfile>. Whilst the structure allows for a lot of effects, it wasnt intended to be a scripting language of its own :) | [reply] |
|
Re: more bracket chaos
by Anonymous Monk on Aug 30, 2007 at 14:14 UTC | |
| [reply] |
by simonodell (Acolyte) on Aug 30, 2007 at 14:27 UTC | |
because doing tricks like that is a very big part of why i feel the system has merit worth discussion. | [reply] [d/l] |
by dsheroh (Monsignor) on Aug 30, 2007 at 15:20 UTC | |
The one caveat with this is that, if the templating tags aren't enclosed in quotes and they look like normal <> HTML tags, then the template will fail to validate as HTML - which is generally fine, so long as the HTML generated from the template is valid. Even so, HTML::Template allows you to use <!--tmpl_var foo--> as an alternative so that the validator will consider it to be a comment rather than a bad tag. (But, then, the same caveat applies to your example with the nested <qd></qd> tags, so I'm not sure why I bothered to mention it...) | [reply] [d/l] [select] |
|
Re: more bracket chaos
by ikegami (Patriarch) on Aug 30, 2007 at 14:15 UTC | |
| [reply] [d/l] |
by simonodell (Acolyte) on Aug 30, 2007 at 14:27 UTC | |
also the commands listed here are a tiny fraction, i have over 30 plugins already defined which can all be used in a very large number of ways because of the bracket type flexibility. | [reply] |
by ikegami (Patriarch) on Aug 30, 2007 at 15:33 UTC | |
You mentioned people fuss about the use of three types brackets. I don't find anything bad with that. (Many sucessful templating system use customs brackets.) At worse, you'll have to escape parens and square brackets in your template. (We need to do the latter here at PerlMonks.) What I find to be the insurmountable obstacle is the possibility that a line a screen down might be executed before the line I'm looking at. You only need a few forms of flow control. No matter how many plugins you have, you'll only have a handful of flow control directives. Too many would just lead to confusion, especially in a template system. Your implication that the number of plugins makes this impractical is nonsense. Perl uses the concept of keywords (if, for, etc) to control the flow. You could do the same (i.e look for special words like "case".) If you want to extend the flow control to the plugins, you might find the approach taken by Paul Lucas in his HTML-Tree templating system (not to be confused with the HTML::Tree parser). The value returned by the plugin controls whether the body of the tag is skipped or not, and whether the tag is repeated or not. This would actually mesh nicely with your existing syntax. Even Perl with its millions of plugins (modules) doesn't need to alter precedence in the manner you suggest*. Unless you have have a context-specific grammar (which would be bad for a templating system), there's no reason for this. * — It has BEGIN, but it's rarely needed. A templating system would not need it. | [reply] [d/l] [select] |
by simonodell (Acolyte) on Aug 30, 2007 at 16:38 UTC | |
by ikegami (Patriarch) on Aug 30, 2007 at 17:09 UTC | |
| |
|
Re: more bracket chaos
by Anonymous Monk on Aug 30, 2007 at 14:29 UTC | |
| [reply] |
by simonodell (Acolyte) on Aug 30, 2007 at 14:37 UTC | |
| [reply] |
|
Re: more bracket chaos
by Anonymous Monk on Aug 30, 2007 at 14:17 UTC | |
People like spongebob :) and its not even lunch yet :p | [reply] |