Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Ruby
Need - macros feature
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Henry Savr, post: 4524395"] There is nothiing new. It's as old as Univac What I want is a classic Macroprocessor tool. I mean: I keep pieces of souce code in some place. They may be included in source code as is. More interesting, you can adjust macroprocessor's output (hence, the input for Ruby interpeter) using paremters. E X A M P L E: =============== You wrote the macro once and put it in macro library (here I "invented" the "macrolanguage" on-fly, while writing the example. I hope, the "language" is clear) ====this is a macro %var with argument %%x definition============== macro: %var (%%x) {def %%x=(value) @%%x = value return @%%x end} ======== end of macro %var definition ============================= You may consider the macro definition as a template. Now, somewhere in your code you write: ... %var(my_lovely_var) ... Once found the %var, macroprocessor should make substitutions and produce this piece: def my_lovely_var=(value) @my_lovely_var = value return @my_lovely_var end which will be inserted into code on the place, where the statement %var(my_lovely_var) was instead of it. Ruby style allows to expect, that it may be done on-fly. So, finally the Ruby interpreter will execute the macroprocessor's output, not input. Besides the macroprocessor's input and output are saved, so you can return to them and change the simple lines of get/set-code to something more complicated and valueable. Again the get/set operations are just an EXAMPLE, used because everyone is familiar with this piece of code. Sure, using attributes is kind of solution for this particular case. (BTW. Thank you, Farrel Lifson, you post convinced me to learn more about attributes on this very beginning stage, and that was very usefull). I want the macro power options themselves. Sure, every language may consider any code as an input string, and process the string, (and Ruby itself is a great for these purposes), but macroprocessor is something very specialized for swiftness and convinience, to do particular job of entering the code. Ruby's macroprocessor tool may be specialized for entering Ruby code, which would make it more powerful. There are plenty of editors with comprehensive macro functions. But they are OS dependent. As Ruby is claimed to be system independent, I would prefer to have Ruby's own macroprocessor, built for Ruby in mind. More I am writing on this topic, more I am thinking, that a highly customized for Ruby editor with macro functions would be the solution... [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Ruby
Need - macros feature
Top