REBOL 3.0

Modules: another EXPORT method proposed

Carl Sassenrath, CTO
REBOL Technologies
9-Dec-2009 20:28 GMT

Article #0300
Main page || Index || Prior Article [0299] || Next Article [0301] || 28 Comments || Send feedback

In R3, modules are easy to create. I've got one for generating HTML pages of all sorts, including web forms for various sites. The module is small, useful, easy to maintain... and before long it will be an integrated part of all the web site WIP wikis (once they move from R2 to R3.)

The HTML module is defined with the header:

REBOL [
   Title: "HTML Formatting Functions"
   Type: module
   Name: html-emit
   Version: 1.2.2
   Author: "Carl Sassenrath"
   Exports: [reset-html emit emit-tag emit-link ...]
]

However, there is a practical matter to consider: I really don't want to maintain the Exports field directly. There are more than 30 words in it.

Some of you know that this issue has been on my mind for several years. In my original modules proposal (long ago) I made serveral suggestions. For example, the header could specify what not to export, then export everything not on that list.

Another solution, one to think about... is to add a keyword into the module making method. The word would be used like this:

export emit: funct ["Emit HTML...

The meaning of export is only important at module load time, where it is used to declare what names are exported. This method works well, because the module's loaded source block is no longer relevant to future evaluation. So, the export words are non-functional.

The main advantage is that the export declaration right next to the function it exports, making maintenance easier.

An alternative that I should mention, because someone will no-doubt mention it anyway is:

#export emit: funct ["Emit HTML...

But, I don't like that as much because issues are not words, they are strings and each one eats memory, where as a word, it wouldn't require any extra memory. (But we need to finish that discussion soon... before alpha is over!)

This export method isn't a change we're going to be making this week, but we need to get your comments, because it will happen sooner or later!

Once you start writing more modules... you'll know what I mean.

28 Comments

REBOL 3.0
Updated 20-Dec-2024 - Edit - Copyright REBOL Technologies - REBOL.net