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

[REBOL] Re: Declaring variables (or words or whatever)

From: greggirwin:mindspring at: 3-Jun-2003 14:30

Hi Steven, SW> I'm having a terrible time getting out of my old ways of thinking. SW> If I want to declare a variable, just because I like to do things that SW> way because it helps me keep track of things, which of these ways is SW> recommended, or they equivalent? SW> TP-FILE-ID: make file! %TPLAYER.DAT ;;; (number one) SW> ... or ... SW> make file! TP-FILE-ID: %TPLAYER.DAT ;;; (number two) SW> ... or ... SW> TP-FILE-ID: %TPLAYER.DAT ;;; (number three) SW> They all seem to work, that is, if I "print TP-FILE-ID" I get the same SW> results, but is one better/more efficient/recommended/better style SW> etc.? I'd use #3 for all general cases. While I don't agree *entirely* with the Agile motto of "Do the simplest thing possible", in this case it works. REBOL understands the value directly, so there is no need to do anything special. In #2 you're just discarding the value returned by MAKE, so it's entirely redundant. Now, #1 doesn't behave exactly like #3, so that's the other thing to consider, and what is one of the hardest things to remember about REBOL when coming from other languages. How you define values, and how you use them, needs to be considered. E.g. print f-1: make file! f-2: f-3: %TPLAYER.DAT f-4: %TPLAYER.DAT print equal? f-1 f-2 print same? f-1 f-2 print same? f-2 f-3 print same? f-2 f-4 append f-2 "XXX" print [f-1 f-2 f-3 f-4] -- Gregg