Calling all idioms!
I want to add some common idioms to R3. Idioms are kind of like the salt you add at the end of the stew. You don't want to add the salt too soon, because you need to taste the flavor first. I've held back on adding idioms over the years, because such things are not very useful unless they get documented. Now that we have the DocBase wiki, that documentation can be added and maintained. Also, idioms don't take much space, and they enhance the language with a standard, meaningful vocabulary. But, in order to qualify, the idiom must be short, clear, useful, and have a good name. If I don't understand the code, it won't get added. And, if a good name cannot be found, then maybe the idiom isn't such a good one? As an example idiom, here's a pattern many of us write fairly often when we write included script files: unless value? 'fee [fee: 10] The line says: if fee is not already defined, then give it a value. It wants a default value for a variable. The idiom could be: default fee 10 Yes, we've talked about this one before. The definition would be: default: func [ "Sets word to a default value if not already set." 'word [word!] value ][ unless value? word [set word value] ] Ok, if you have a favorite, you can post it using the R3 CHAT command under #754 (R3/Idioms). If you do not have R3, watch the website over the next day or so. If you cannot wait, or do not plan to try R3 soon, then you can post it here in the comment section or on one of the many AltME worlds where someone can relay it to the R3 team.
|
Updated 14-Nov-2024 - Copyright Carl Sassenrath - WWW.REBOL.COM - Edit - Blogger Source Code |