Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Interface to A J Martin's ML dialect

 [1/5] from: tim:johnsons-web at: 27-Aug-2003 7:51


Hello Rebols: It's my hope that some day RT will be releasing rebol with packages. I know that there are many good ones out there, from my own experience, I vouch for 'ML and mysql-protocol. I use 'ML extensively and I'm combining the dictionary approach that I use in python for building dynamic web content with the 'ML dialect. I note from Carl's Designer's Tip Sheet that came with my copy of Rebol The Official Guide Tip # 4 - Data Drives It. It's become my motto. It is useful then to have a function(s) that processes blocks of rebol words and values and then delivers them to 'ML to do the processing that is so much more efficient than the python HtmlGen module. I've include some preliminary code here mostly for Andrew's comments and guidance but for others that might be interested. Certainly, 'ML deserves more exposure. The test module uses ml-lib.r which is viewable at http://www.johnsons-web.com/demo/ml-lib.r.html This contains Andrew's 'ML function, along with dependencies and source for the 'def subroutine and the 'htm shorthand function. the test module itself is at http://www.johnsons-web.com/demo/mu.r.html the 'def block that you see in this code is a shorthand for Andrew's Sub function that generates local variables automatically. 'htm is shorthand for ML with compose/deep. I would welcome comments and criticisms. This is just a small starting point. I plan on adapting my entire python module that I've written to a more rebolesque fashion, so much more functionality is obviously going to be added. Thanks! tim -- Tim Johnson <[tim--johnsons-web--com]> http://www.alaska-internet-solutions.com http://www.johnsons-web.com

 [2/5] from: AJMartin:orcon at: 28-Aug-2003 18:21


Hi, Tim. Tim wrote:
> I would welcome comments and criticisms. This is just a small starting
point. Can you expand more on the end goal, please? I don't know where the starting point at http://www.johnsons-web.com/demo/mu.r.html is going to lead to. Thanks! Andrew J Martin ICQ: 26227169 http://www.rebol.it/Valley/ http://valley.orcon.net.nz/ http://Valley.150m.com/

 [3/5] from: tim:johnsons-web at: 28-Aug-2003 7:47


* A J Martin <[AJMartin--orcon--net--nz]> [030827 22:33]:
> Hi, Tim. > Tim wrote:
<<quoted lines omitted: 3>>
> point at http://www.johnsons-web.com/demo/mu.r.html is going to lead to. > Thanks!
Hi Andrew: I'm up to my neck in work today, so I'm going to 'dump' a simple example of a python dictionary that I use for one form, (the login form, not the 100-field survey). Here's the python structure: login_dict = [ # not a true dictionary, but does become one in the process 'email', { 'type':'text', 'attrs':{'llabel': 'Email Address', 'lj': 0, 'size': 30,'req':1,},}, 'password', {'type':'text', 'attrs':{'llabel': 'Password', 'lj': 0, 'size': 30,'req':1,},}, ] # true and tested data structure ; lj = left justified, llabel = label to left, rj, rlabel ->right etc ; other pseudo-attributes would be 'link (relational tables in database) ; now here is the proposed rebol structure of the same functionality ; UNTESTED! login-dict: [ email [ ; name, may have to be a string type "text" txt[llabel "Email Address" lj 0 req 1] ; text attributes att[size 30 maxlength 40] ; 'htm attributes ] password [ type "password" txt[llabel "Email Address" req 1 lj 2] att[size 20 maxlength 30] ] ] ; in the case of a set of radio buttons, the 'txt/'att structures ; would be nested in an outer block ; And further 'up the line' either of these data structures might ; be generated (at least in one pass) by parsing a static web form ; or even from a database. I hope this makes it a little clearer. BTW: the python dictionary (of the {key: 'value'} structure is a implementation of a binary tree in the "C" source, and is very fast at runtime. Does rebol have anything comparable ("under the hood")? tim
> Andrew J Martin > ICQ: 26227169
<<quoted lines omitted: 5>>
> To unsubscribe from this list, just send an email to > [rebol-request--rebol--com] with unsubscribe as the subject.
-- Tim Johnson <[tim--johnsons-web--com]> http://www.alaska-internet-solutions.com http://www.johnsons-web.com

 [4/5] from: brett::codeconscious::com at: 29-Aug-2003 23:34


> BTW: the python dictionary (of the {key: 'value'} structure is a > implementation of a binary tree in the "C" source, and is very fast > at runtime. > > Does rebol have anything comparable ("under the hood")? > tim
If you had a large number of keys to search then REBOL has the hash! datatype. But I'd be suprised if it were faster than using block! like you are now for anything less than about 150 items. I haven't measured it - just a guess. If you end up with a functionally similiar REBOL script to your Python code it would be interesting to know how they compare in performance. Regards, Brett.

 [5/5] from: tim:johnsons-web at: 29-Aug-2003 7:46


* Brett Handley <[brett--codeconscious--com]> [030829 05:49]:
> > BTW: the python dictionary (of the {key: 'value'} structure is a > > implementation of a binary tree in the "C" source, and is very fast
<<quoted lines omitted: 4>>
> If you had a large number of keys to search then REBOL has the hash! > datatype.
Correct.
> But I'd be suprised if it were faster than using block! like you > are now for anything less than about 150 items. I haven't measured it - just > a guess.
I have built dynamic forms with over 300 fields. (hated it!)
> If you end up with a functionally similiar REBOL script to your Python code > it would be interesting to know how they compare in performance.
I will be doing some comparisons, but regardless of who comes out on top, the difference at runtime is not likely to be as significant as ease of coding and maintenance. Python makes you jump through more hoops coding-wise, but has a way of 'forcing' a discipline that one has to conciously employ with rebol..... Interesting enough, although I haven't seen it covered explicitly in this list, the use of an anonymous context is more of sure-fire way of controlling data encapsulation than is a named context or python classes... tim
> Regards, > Brett. > > -- > To unsubscribe from this list, just send an email to > [rebol-request--rebol--com] with unsubscribe as the subject.
-- Tim Johnson <[tim--johnsons-web--com]> http://www.alaska-internet-solutions.com http://www.johnsons-web.com

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted