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

[REBOL] Re: serious proposition...WAS: RE: Standards

From: andrew:martin:colenso:school at: 24-Dec-2003 22:45

Max wrote:
> I'd like an OFFICIAL, community blessed library/module standard.
A lot of us are still waiting for Carl's module standard to arrive. I've given up on the idea of waiting, though I can see how useful it would be. Max, can you give an example of your proposed library module, please? Perhaps for a function that depends upon the presence of another function (or word definition)? Here's my example of 'Address and the word ('HTML_Obfuscate) that 'Address relies upon: [ Rebol [ Name: 'Address Title: "Address" File: %"Address.r" Author: "A J Martin" Owner: "Aztecnology" Rights: "Copyright (c) 2003 A J Martin, Aztecnology." eMail: [Rebol--orcon--net--nz] Web: Needs: [%HTML_Obfuscate.r] Tabs: 4 Purpose: { Writes ML dialect for current script's File, Date & Version, along with the script's Author, email and web address. } Language: 'English Date: 19/July/2003 Version: 2.7.2 ] Address: has [File Date Version] [ File: Rebol/script/header/File Date: Rebol/script/header/Date Version: Rebol/script/header/Version compose/deep [ div/class "Address" [ address [ (rejoin ["Script: " File "; Date: " Date ; Version: Version "; "]) "Author: " a/href/title ( rejoin [ "mailto:" HTML_Obfuscate Rebol/script/header/eMail "?subject=" "Script: " replace mold File #"%" "%25" "; Date: " Date "; Version: " Version #"." ] ) "Send email about this script to the author" (Rebol/script/header/Author) "; " "Web: " a/href/title (Rebol/script/header/Web) "Go to the author's web site" (Rebol/script/header/Web) #"." br ] ] ] ] ] [ Rebol [ Name: 'HTML_Obfuscate Title: "HTML_Obfuscate" File: %"HTML_Obfuscate.r" Author: "A J Martin" Owner: "Aztecnology" Rights: "Copyright (c) 2003 A J Martin, Aztecnology." eMail: [Rebol--orcon--net--nz] Web: Tabs: 4 Purpose: {Obscures text by converting characters into HTML entities.} Language: 'English Acknowledgements: "Brian Hawley" Date: 17/July/2003 Version: 2.0.8 ] HTML_Obfuscate: function [Plain [string! email!]] [Out] [ Out: make string! 6 * length? Plain foreach C Plain [ C: to-integer C Out: insert Out reduce [ "&#" any [ if C < 10 ["00"] if C < 100 [#"0"] "" ] C #";" ] ] head Out ] ] The nice part is that my library script, %Values.r, loads each script in the library directory, %Values/, and interprets the 'Needs block. If %Values.r finds a file! value, it loads that script (and checks the 'Needs block, recursively), before 'do-ing the first script. This system has the advantage that I can simply copy any library script that I like into the %Values.r directory and it runs when any version of Rebol is launched. (I've got the line: do %/C/Rebol/Values/Values.r in my %User.r file.) I've recently realised that there's some disadvantages in the above system in that it's file-centric, instead of word-centric. That is, the 'Needs field refers to file! values rather than word! values. It also lacks a way of describing what words are given values to by each library/values script; in other words, the above needs a 'Provides (or similar word) name-value in the header. For example, my %Dir.r script has this content: CD: :change-dir LD: :list-dir MD: :make-dir WD: :what-dir There should really be a Provides in the header like: Provides: [CD LD MD WD] And for my first library script: %"Address.r", like: Provides: [Address] Needs: [HTML_Obfuscate] With this change, I can then have my library script automatically check the library directory and create one script file with all the library functions on it, to maximise the OS caching of files and to speed Rebol's interpretation of the startup script by processing only one file instead of dozens of files. If I were to use any other library manager, it would have be as simple to use as the above. I'd like to know more about your module system. Andrew J Martin Attendance Officer Speaking in tongues and performing miracles. Colenso High School Arnold Street, Napier. Tel: 64-6-8310180 ext 826 Fax: 64-6-8336759 DISCLAIMER: Colenso High School and its Board of Trustees is not responsible (or legally liable) for materials distributed to or acquired from user e-mail accounts. You can report any misuse of an e-mail account to our ICT Manager and the complaint will be investigated. (Misuse can come in many forms, but can be viewed as any material sent/received that indicate or suggest pornography, unethical or illegal solicitation, racism, sexism, inappropriate language and/or other issues described in our Acceptable Use Policy.) All outgoing messages are certified virus-free by McAfee GroupShield Exchange Phone: +64 6 843 5095 or Fax: +64 6 833 6759 or E-mail: [postmaster--colenso--school--nz]