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

[REBOL] Re: Dumb newbie Rebol question

From: greggirwin:mindspring at: 4-Sep-2003 22:20

Hi Brian, (or do you prefer Parki?) BP> Wow - help on this list is great. Yes, it is. Part of why I love REBOL is the people it attracts. BP> 1. Data encapsulation - is there any convenient way to make data BP> readonly in an object? I need to define some constants, and I want to BP> put them in an object so as to not clutter up the namespace. Not really. I had the same issue when I started with REBOL, but I haven't missed them (constants) for a long time. One thing that helped me was when I tried to emulate ENUM functionality in REBOL ("How could they leave that out?!" :). At some point in the process, I realized that I didn't really need the numeric values for anything; what I wanted were the human-friendly words that were unique in a list. From there it was a short jump to just using a block of words and using the literal words themselves. Another thing that I think has helped me is keeping things small and using objects to prevent "accidents". Rather than blindly including every API constant listed in a Windows header file (as I would do under VB), I include only those I need, maybe putting the others in as comments. I had a hard time getting out of my strong OO mindset and into a more build just what you need right now kind of mentality, and I still have issues to sort out myself, but it *can* work. :) Maybe if you show us exactly what you're wanting to do, we can make some suggestions. That's another thing about REBOL, you can often come up with a great *specific* solution that is not easily generalizable. BP> 2. Any way to enforce some sort of Singleton idiom? I suspect that BP> asking this (and perhaps the above) are caused by not enough BP> indoctrination to the Rebol way of doing things, but wondering... I am BP> going to put the serial connection code into an object (again, keep BP> namespaces clean) and in Java, I'd make this a Singleton, as I only BP> want one serial connection open. Not sure how this should be tackled in BP> Rebol. Same kind of deal. There's no mechanism to enforce it, but you just create "the one" and use that. Maybe you end up with an outer object that contains your serial singleton object, so he's the one responsible for not creating more than one of them. Again, looking at the specific case will sometimes lead to ideas about an architecture. Lexical scoping is another tool you can put to good use in REBOL. BP> Hot dang - this is a fun language! I couldn't agree more! :) -- Gregg