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

[REBOL] Re: [ A world of words ] naming convention, namespace, namespace pollut

From: nitsch-lists:netcologne at: 28-May-2003 14:41

Marc Meurrens wrote:
> Hello, > > [ A world of words ] > naming convention, namespace, namespace pollution, good practises, > coding styles > + > multiple inheritance in the example > > As things are going on, I feel the necessity to organize a little bit > the names I use. > I mean, as well, names for script *files* > and names for *words* used to store my values. > I did not find on the web or by reading existing scripts > something like a "convention", a "tradition" > { tradition may be incompatible with rebolution -:) ??? } Eventually get an IOS-account, there are some original rt-style-apps.
> > The need arises from several reasons > --- avoid clashes, namespace pollution, etc in my own works > --- avoid clashes in a cooperative/collaborative process as permitted > by REBOL > do
my-module: context[ .. ] you have to take care you made all words local. Either by function-locals or by having them as set-words in the top-level. means, here 'a is local, but 'b is global. : ctx: context[ a: 123 do [b: 234] ] because the context-builder did not look in the inner block. a good way to check if you made something global: query/clear system/words do %script.r probe query system/words
> --- readability/documentation/sharing knowledge > --- deal with "no private/public in REBOL objects" (as for PHP, etc) > { I allways prefix all private things with "_" (underscore) }
with series, 'find and all the inbuild stuff i rarely need a lot of fields. public/private or deep object-hierarchies are waste of time with typical script-sizes IMHO. stuff like files: [%file1.r as-text %file2.r as-binary] foreach [file mode][either 'as-text = mode[..][..] ] saves some declarations :)
> --- deal with "no object strong typing in REBOL" (as for PHP, etc) > --- deal with "no return type in function signature"
keep a console open. often you can try the function and look at its result. rebol needs not much initialisation, so trying out is often as fast as switching to help-window.
> --- deal with "case insensitive in REBOL" > {no camelBack convention, but we may still decide to use it on a > voluntary basis} > {no ALL_UPPER_CASE convention, but we may still decide to use it > on a voluntary basis}
personally, dealing with camelBack is harder ;)
> --- existing scripts show an extensive use of "-" (minus) but not "_" > (underscore) > Any reason ???
rebol does it. and it saves shift-keys :)
> --- availability in the names of "special" characters such as "?" "!" "#" > that have/should have/receive a "universal conventional" meaning.
length? something. inbuild datatypes are marked integer!
> Below are some of my current ideas/practises. > Together with a short example. > But before deciding/publishing/re-inventing the wheel/etc, > I'll like to know if there exists already some "good practises". > ?????????? > > When do you use *.r or *.reb or even *.rebol ??? > (*.rip is for archives) > > Do you use some other extensions ??? > (a part of *.exe for Win32 executables of course) > e.g. to store images converted to REBOL binaries, etc, etc ??? > as > %rebol-logo_83x31.jpg.r
*.r for files which can be loaded, *.txt for texts. RT uses *.rcb for rebol-compressed binary (~zip) and some other extensions.
> Do you use prefixes for your script names ??? > such as > %i-my-script.r ;;; defines a unique value : i-my-script , an interface > definition block > %o-my-script.r ;;; defines a unique value : o-my-script , an > implementation definition block > %my-script.r ;;; defines a set of values > %v-my-script.r ;;; a so-called events driven "application" using > REBOL/VIEW > %c-my-script.r ;;; a so-called "application" using REBOL/CORE > my-script.exe ;;; compilation of %v-my-script.r for WIN32
with lots of files i prefer %module-name-type.r . file-requestors sort by module, and *-type.r selects the file-type. IOS prefers simple names and subdirectories.
> Special names for files holding data ??? preferences ??? > configurations ??? > a part from the well known > %user.r > %preferences.r > something like ??? > %my-script.ini.r
on IOS a lot %prefs.r . And variable-style filenames.
> > How do you define an "application" ??? > How do you define a "reblet" ??? > Do you have conventions to let know that a given file > is just a set of values, or is a "reblet" ??? an application ???
reblets have larger headers :) I use "reblet" to interface a server and demos on rebsites. application means standalone.
> Do you use special conventions for naming your words ??? > such as > ?my-object ;;; help function > ?my-object-my-value ;;; help function > my-word? ;;; returns a logic (boolean)
my-word? for others i would use a word instead of "?", about-my-object or something. btw, console has tab-completion, so abo^tab is not to much typing ;) And help with a string shows all words with the string inside, like help read
> what about other special characters, such as "# " and "!" ??? > when used as the first letter??? as the last??? > Is there a consensus in the community on how/when to use them ???
i guess consensus is, not as first letter.
> Do you use something like an hungarian prefix ??? > such as in the following script
when using /view, i often have the same name for a variable and its face, so i call the face f-variable-name. sometimes i use hungarian postfix (variable-face).
> { demonstrating also so-called "multiple inheritance" > and the " interface v. body" pattern > we initially developped for JAVA in an anterior and still parallel life } > > Do you use "multiple inheritance" ??? > (does not replace "composition"...!)
not conscious.
> Do you use upper/lower cases for documentation purposes ??? > such as > A_NOT_SO_GOOD_PI: 3.14 ;; constant
loong ago there was the preprocessor, and it was handy and smart and did not know nothing about lexical scopes. So peoples wrote BE_WARNED in very big letters. Also it says: this is an integer which wants to be an enumeration. here we use if 'as-text = mode [] no need to bring the integer-step in, no need for warning. So with Rebol, why? :)
> Do you use indentation conventions > and some other coding syles ???
%clean-script.r, open brackets are the last on the line, closing brackets have their own line. 'any / 'all instead of 'if, when possible. func[a /local b] instead of function[a][b]