Absolutely.  That fun, and then the not ACTUALLY implicit knowledge,
but so-complicated-it-may-as-well-be-implicit-knowledge goodness of
how you get (from a MEL perspective) from creating a float attribute,
to bloody using it.  From (double) to reading it in a node (blah blah
blah.asFloat() ) to changing it for a command to be used or read back
from (MScriptUtils, pointers).  Again, from a MEL perspective, a
simple decimal number has taken on 5-6 forms based on the context you
want to use it, and there's just nothing tying it back together to
thinking of it as a decimal number.  I'm hoping to beat some of that
down at the link in the first message.

Tim, on that, may I re-post your message on my site? (credit paid, of
course)  I think that information is invaluable, and the more places
someone can stumble on it, the better.

On Feb 15, 3:46 pm, Ofer Koren <[email protected]> wrote:
> Keep in mind this documentation is for the C++ API, where all this makes a
> lot more sense. It doesn't always have direct translation in python (hence
> the notorious MScriptUtils).
>
>
>
> On Sun, Feb 15, 2009 at 2:51 PM, Tim Fowler <[email protected]> wrote:
> > "const" means that the parameter is constant and the compiler will not
> > allow changing its value.
>
> > "&" is a reference to a particular parameter.  If you call a function with
> > a parameter that is not a reference then a copy is made of what you passed
> > in.  If it is a reference then basically the caller and the function are
> > both pointing to the same place in memory and any edits the function makes
> > to it will be seen by the caller.
>
> > For objects that are non-trivial it can be quite time consuming to make
> > copies to be passed to functions so it is common to pass these objects
> > around "by reference".  If you don't want the function changing anything in
> > your object, but you also don't want to be spending the time copying it then
> > you can combine a reference with const and have a "const reference".  eg.
> > one of the constructors for MAngle takes in a const reference to another
> > MAngle.  In this example there isn't a copy made of "MAngle src" but if the
> > constructor tried to change something in src then there would be a compiler
> > error spit out.
>
> > * is a pointer to a location in memory.  When you say something like
> > "SomeObject * var;" this means that var is a variable which stores a memory
> > address and that the object at that location in memory is of type
> > "SomeObject".
>
> > Passing pointers to objects, instead of the objects themselves, is like
> > passing the object by reference in that just a copy of the pointer is made
> > instead of copying the actual object.
>
> > When you declare a function parameter like this: "bool calculateExactHit =
> > false" this means that that paramater is optional and if the caller doesn't
> > specify a value for it then what you have provided there will be used.
> > You can have a mixture of non-optional and optional paramaters in a
> > function.
> > eg.
> > void someFunction(int a, int b, int c = 5, int d = 5);
> > could be called like:
> > someFunction(1, 2)           <- c and d will both be 5 here
> > someFunction(1, 2, 3)       <- c will be 3 and d will be 5
> > someFunction(1, 2, 3, 4)   <- c will be 3 and d will be 4
>
> > In this example of yours:
>
> > bool calculateExactHit = false,
> > bool * wasExactHit = NULL,
>
> > calculateExactHit is a boolean and if you don't specify a value for it then
> > the function will use false.
>
> > wasExactHit is a pointer to a memory location, and the value at that
> > location in memory should be interpreted as a boolean.  NULL is a special
> > value for pointers that basically says that it's not really a memory
> > location, or it's not initialized to something yet.  So if you don't specify
> > something for "wasExactHit" then the pointer will be set to NULL.  Then in
> > the implementation, the function can compare the value to NULL to determine
> > if it's valid or not.
>
> > That probably doesn't answer everything you've asked...but might get you a
> > little farther along  :-)
>
> > On Sun, Feb 15, 2009 at 5:16 PM, jasonosipa <[email protected]> wrote:
>
> >> What do const, &, and * each mean?
>
> >> When you look at documentation for an object, each argument can have a
> >> lot of different markup, and I'm not confident with guesses at what
> >> those mean, so I'll just ask:
>
> >> What do const, &, and * each mean?  What does "blank" mean, where
> >> there is no const at the head of the line, and no * or & ?  How about
> >> the stuff after the = in the argument?  Is that just a "recommended
> >> default"?  Does const only show up for things that are MObjects?
>
> >> Why is it that something like these two argument lines:
>
> >>  bool calculateExactHit = false,
> >>  bool * wasExactHit = NULL,
>
> >> Both seem to be booleans, but one has no markup, and what looks like a
> >> "default suggestion" of false, which fits into the idea of a boolean,
> >> whereas the second has a star between, and then has a "default
> >> suggestion" of NULL.  Are those not default suggestions?  If they are
> >> - I'd have to use  None not NULL in python, right?  Knowing what
> >> const, & and * each means is the answer to all of these questions,
> >> isn't it...
>
> --
>
> - Oferwww.mrbroken.com
--~--~---------~--~----~------------~-------~--~----~
Yours,
Maya-Python Club Team.
-~----------~----~----~----~------~----~------~--~---

Reply via email to