If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
NEW REGISTRATIONS - please contact us if you wish to register on the forum
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
Ruby (learning and language comparisons)
Re: Ruby (learning and language comparisons)
.
Last edited by MichaelBenjamin on Mon Sep 21, 2020 10:34 am, edited 1 time in total.
- MichaelBenjamin
- Posts: 275
- Joined: Tue Jul 13, 2010 1:32 pm
Re: Ruby (learning and language comparisons)
MichaelBenjamin wrote:i guess the ? operator still eludes me
In the way I used it, it's not an operator - it is literally just part of the method name, as tulamide said. Method names can also end with the '!' character (usually meaning "watch out, this method is potentially dangerous").
MichaelBenjamin wrote:so i guess this also applies to FS ruby codeboxes
Yes, the only difference between the two is in the scopes for name lookup. Code boxes are able to see variable and method names of the enclosing scope, in much the same way that Python can have function definitions within the body of a method which do the same thing.
MichaelBenjamin wrote:would it compile?
As far as I can see, yes. The only slight fly in the ointment is that "class" would override the built-in method for reading an object's class, so is usually avoided; but I don't think it would do any harm in practice (the "kind_of?" method would normally be used anyway).
i also would like some apology from tulamide for calling my writing "toxic", when it isn't.
I feel pretty insulted by this.
You find this word too strong, just as he found "gulag" too strong (imagine how someone who survived such punishment might feel about such casual use of the term). The word "toxic" has lost all meaning to me in this context, and I read little into it, as it now seems to be just internet shorthand for "distasteful in some sense; maybe strongly, maybe mildly, it's anyone guess" (what some linguists now call a "skunked term", just as "gulag" has become through over-use).
As a moderator, I have no control over what people percieve to be a personal attack, but I don't see that either of you intended one. My opinion is that you both phrased your arguments in slightly stronger language than strictly necessary for rhetorical effect, as we all do at times. He has continued to help you, just as you have accepted that his examples are useful. Not really worth falling out over, IMHO.
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
Don't stagnate, mutate to create!
-
trogluddite - Posts: 1730
- Joined: Fri Oct 22, 2010 12:46 am
- Location: Yorkshire, UK
Re: Ruby (learning and language comparisons)
.
Last edited by MichaelBenjamin on Mon Sep 21, 2020 10:35 am, edited 1 time in total.
- MichaelBenjamin
- Posts: 275
- Joined: Tue Jul 13, 2010 1:32 pm
Re: Ruby (learning and language comparisons)
.
Last edited by MichaelBenjamin on Mon Sep 21, 2020 10:35 am, edited 1 time in total.
- MichaelBenjamin
- Posts: 275
- Joined: Tue Jul 13, 2010 1:32 pm
Re: Ruby (learning and language comparisons)
.
Last edited by MichaelBenjamin on Mon Sep 21, 2020 10:35 am, edited 1 time in total.
- MichaelBenjamin
- Posts: 275
- Joined: Tue Jul 13, 2010 1:32 pm
Re: Ruby (learning and language comparisons)
MichaelBenjamin wrote:ruby actually seems to be pretty similar to python in that regard
I find the "fan-boys" who argue about which is better quite comical sometimes - my experience is that, besides syntax details, they're really not much different at all. The main difference when it comes to method definitions is just that in Ruby the "self" is always implied so, like C++, you don't need to write an argument for it or prefix calls to an object's own methods within the class definition.
Even the code-block thing isn't that different, really. It's equivalent to passing a function (function-pointer in C++) as a method argument, except that the function has no name, and some internal optimisation is possible because the anonymous function is unique to a specific call-site.
MichaelBenjamin wrote:how about array/list access? i guess ruby only has a generic list by default
Yes, the Array class is a generic flat list, with a bit of syntax-sugar to allow them to be declared with a literal (e.g. array = [1, 2, 3, 4]) and to allow the usual square-brackets operators for element look-up and assignment. There also a built in associative array called Hash, which is pretty much the same as a Python Library.
And you guessed right; animal.size() or animal.length() would get you the number of animals -though the parentheses are normally omitted for a method with no arguments.
MichaelBenjamin wrote:also regarding flowstone - when is a ruby codebox refreshed/recalculated/recompiled-and-evaluated?
The "compilation" is done literally every time you type a character in the code-editor. It's pretty handy in that you get to see any syntax errors right away, though it does slow down editing for code that's getting to be hundreds of lines. Naturally, it also happens at startup, toobox-dragging, or pasting from the clipboard.
Execution, as you say, is whenever a new input is received. If the Ruby is just plain code without any method definitions, the whole of the code gets executed every time. If you've defined methods, it will try to call the "event" method instead (the "init" method, if you have one, is always called after every "compilation", at the times noted above for that).
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
Don't stagnate, mutate to create!
-
trogluddite - Posts: 1730
- Joined: Fri Oct 22, 2010 12:46 am
- Location: Yorkshire, UK
Re: Ruby (learning and language comparisons)
.
Last edited by MichaelBenjamin on Mon Sep 21, 2020 10:35 am, edited 1 time in total.
- MichaelBenjamin
- Posts: 275
- Joined: Tue Jul 13, 2010 1:32 pm
Re: Ruby (learning and language comparisons)
Yes, every trigger for the 'green' RubyEdit inputs. Inputs which take a "Frame" that's been grabbed from a blue stream get fired once per VST/driver buffer, but those aren't used very often. Likewise, the "output" method always sends something to a green output and generates a trigger.
The methods are probably best thought of as 'member functions' which belong only to the RubyEdit where they are defined, and you could think of the instance variables (the "@name" variables) as being its 'data members' - they all share the same implied 'self', which is the actual RubyEdit. The internal implementation is complicated a bit by how Ruby is embedded into FS, so I wouldn't worry about that too much.
Generally, they're always called 'methods', though you sometimes hear 'functions' strictly for the case where the 'self' object or its members are never accessed - i.e. input arguments -> calculation -> result.
The methods are probably best thought of as 'member functions' which belong only to the RubyEdit where they are defined, and you could think of the instance variables (the "@name" variables) as being its 'data members' - they all share the same implied 'self', which is the actual RubyEdit. The internal implementation is complicated a bit by how Ruby is embedded into FS, so I wouldn't worry about that too much.
Generally, they're always called 'methods', though you sometimes hear 'functions' strictly for the case where the 'self' object or its members are never accessed - i.e. input arguments -> calculation -> result.
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
Don't stagnate, mutate to create!
-
trogluddite - Posts: 1730
- Joined: Fri Oct 22, 2010 12:46 am
- Location: Yorkshire, UK
Re: Ruby (learning and language comparisons)
.
Last edited by MichaelBenjamin on Mon Sep 21, 2020 10:35 am, edited 1 time in total.
- MichaelBenjamin
- Posts: 275
- Joined: Tue Jul 13, 2010 1:32 pm
Re: Ruby (learning and language comparisons)
MichaelBenjamin wrote:also, bonus question:
why do you write e.g in englisch, which i guess means something latin like ex generis, and not write f.e. like for example? bcs in german we use the appropriate z.B., for zum Beispiel
All european languages are based completely or in great part on latin - the Romans just spreaded everywhere. Later on, Latin was the official language, used by those who could read and write (mostly clerics). That's why many Latin words are still part of a european language, for example the Latin "temperare" is used as "temper" in English and "temperieren" in German or "tempérer" in French.
We Germans also have Latin abbreviations, that we use, like n.b. (nota bene, übrigens), ca. (circa, ungefähr), etc. (et cetera, und so weiter und so fort), p.s. (post scriptum, Nachsatz) and many more.
Appropriate is to use, what that language usually uses. But nobody stops you from using "for example" (as I did a few lines above).
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Who is online
Users browsing this forum: No registered users and 64 guests