Is it possible for me to set my boolean variable to true and false at the same time? - variables

The program I'm writing, or at least what I have written of it so far, really relies on this somehow working.
If anyone could come up with a direct solution that would be really appreciated, but if it's impossible (or at least really improbable) then I guess a workaround would work, but it would be extremely inconvenient to my work.

That sort of goes against the definition of a boolean.
You could create your own custom structure that can be any of 3 states instead.

Related

Using 'should' in function names

This is a question with no definite answer so apologies if I posted this wrongly however at my place of work alot of the code I see written by our developers have function names with the keyword 'should', must I add they base this on 'should' and 'should not'. From a point of semantics, whats your view on this? I've mentioned before that I don't believe this should be used because it has too many possibilities (where does it end) however they insist its a good practice.
Example use;
$this->it_should_render_template_partially($params);
$this->it_should_show_module_parameters($params);
$this->it_should_not_return_module_parameters($params);
I am curious on others thoughts. Just to add, this is production code and not unit tests.
While I like long, descriptive, names, I don't like redundancy. When I read the documentation of a function, I expect it to do what it is supposed to do. Yes, functions are written by humans that make a lot of mistakes, so they can have bugs, which means they do not behave as intended. But this is implied when one uses a function. We hope that out functions do what they should (and we try to make sure that is the case using tests). But specifying the should part in the name of a function is just redundant, which is, in my opinion, a bad practice, as it results in longer names, harder to read/write.

What is the benefit of using raw_native_types?

I've encountered the raw_native_types in a tlb import statement and I'm unclear of what the benefit of this attribute is. I've read the MSDN description for this (http://msdn.microsoft.com/en-us/library/8etzzkb6%28v=vs.71%29.aspx#_predir_raw_native_types) but it hasn't helped clearing it up for me. Can someone help explain it to me?
Thanks.
The intention defines the benefit. If one really doesn't want to use _bstr_t or _variant_t because, who knows, one abominates them (not that uncommon), or one doesn't trust the compiler to actually do a good job at keeping them alive, or one already uses other smart wrappers, or one really likes to explicitly call SysFreeString and VariantClear, then one specifies raw_native_types.

Is there a good way to determine if a variable is referencing a user defined function?

The isValid function doesn't support this capability as far as I can tell, and there is no built-in "isUDF" or "isFunction" function. So far, the best I've been able to come up with is
findNoCase("func", myUDF.getClass.getSimpleName()) neq 0
When used on a UDF, the Java method getClass().getSimpleName() always seems to return a value with the substring func in it. I know very little about Java, though, so I have no idea how reliable this is.
Is there a better way to identify a reference to a function?
isCustomFunction() or isClosure(). CFML should not require two functions here, but due to - I suspect - poor understanding of the concept of closure on the part of the Adobe ColdFusion team, they kinda messed this up. Commentary on this: "Am I right to think this is stupid?"

Modelica - how to implement a constructor for a record

What is the best way to implement a constructor for a record? It seems like a function should be able to return a record object in the instantiation of the record in some later model higher up the tree, but I can't get that to work. For now I just use a bunch of parameters at the top of the record that populate the variables stored in the record, but it seems like that will only work in simple cases.
Can anyone shed a little light? Perhaps I shouldn't be using a record but a model. Also does anyone know how the PDE functionality is coming? The book only says that it is coming, but I have seen some other things around.
I don't seem to have the clout to add tags (which makes sense, since my "reputation" is lower than yours) so sorry about that. I thought I had actually added one at one point, but perhaps I am mistaken.
I think you need to be clear what you mean by constructor since it has a very specific meaning in Modelica. If I understand your question correctly, it sounds like what you want to do is create an instance of a record that has some fields that are specified in the constructor arguments and from those arguments a bunch of other fields in the record are computed. Is that correct?
If so, there is a mechanism to do this. You mention "the book" but it isn't clear which one you mean. If it is mine, it definitely has no mention of these so called "record constructors" because it is too old. I do not know if Peter Fritzson's book mentions them either. However, they do exist and are documented in Section 12.6 of the Modelica 3.2 specification.
As for PDEs, there has been work into this kind of thing but nothing has really been done within the design group on this topic. I would add that if you want to solve either elliptical or parabolic PDEs on regular grids, this isn't too hard even with the current language. The only real drawback is that most tools probably don't handle sparsity very efficiently. Irregular grids would also be possible, but then you get into complicated basis functions. Finally, hyperbolic PDEs are, in my opinion, quite tricky (in any environment) due to the implicit physical constraints between time and space which are difficult to express (i.e. the CFL condition).
I hope that answers your questions so far.
I can only comment on your question regarding the book of Peter Fritzson. He confirmed that he's working on an update and he hopes to get it ready 'in the course of 2011'.
Original post here:
http://openmodelica.org/index.php/forum/topic?id=50
And thanks for initiating the modelica tag, I might be useful in the near future for me too... :-)
regards,
Roel

Trying to grab integer from pre-defined p-list? ObjC/Cocoa

I'm working on an Objective-C/Cocoa roguelike, because I've always found that working on a game is the best way to learn about a language. I've gotten quite far with my game, but I'm having a problem.
Each level.plist is defined with a few things, like so:
<key>Save Location</key>
<integer>0</integer>
It's grabbed like so, I'd also like to say that this code is all working fine:
NSObject* level = [mapDictionary_ objectForKey: kLevelNumberKey];
However, in my NSLog-exploring, I've found that instead of grabbing me an integer, or even a useful number, this grabs me an object of some sort, which returns the correct value when NSLogged. How would I go about making this value into an integer so that I can use it like I'd want to be? Note that I've only used NSObject* because nothing else worked right. If I used =(int) instead I would get the pointer value or whatever (1108608 for example).
I'm sure it's a simple solution, and I thank you in advance. If you would not mind explaining exactly what is happening, that would be great. My grasp of the concepts is fine, better than most newcomers, but I'm always interested in exactly what is happening. What use would learning to program be if I didn't know what was going on! Please be more than willing to advise me of other situations like this to watch out/be ready for as well. Any advice, really is appreciated, and will be going to somebody who intends to code for a very long time. I put off learning this much too long, my only regret is not starting earlier.
If, for whatever reason, you are interested in trying out my game so far: Link I'm currently in the process of implementing state-saving so that levels remain as you left them. It's obviously OS X only. I'm pretty proud of it so far, but I have a long ways left. The controls are listed in the app.
The value is an NSNumber object. You can get it as an int using the -intValue method
More details about Property List types