Search Results

Search found 215 results on 9 pages for 'precedence'.

Page 1/9 | 1 2 3 4 5 6 7 8 9  | Next Page >

  • Java operator precedence guidelines

    - by trashgod
    Misunderstanding Java operator precedence is a source of frequently asked questions and subtle errors. I was intrigued to learn that even the Java Language Specification says, "It is recommended that code not rely crucially on this specification." JLS §15.7 Preferring clear to clever, are there any useful guidelines in this area? Here are a number of resources on the topic: JLS Operators JLS Precedence Java Glossary Princeton Sun Tutorial University of West Florida Usenet discussion Additions or corrections welcome.

    Read the article

  • rules precedence in bison

    - by arbiadr
    Hi Here is the grammar rules: ProcessExpression : EventExpression "->" ProcessExpression | ProcessName ; Please can you tell me how can I tell to bison that the first rule has the highest precedence than the second one? I have tried: %nonassoc PROC %right "->" ProcessExpression : EventExpression "->" ProcessExpression | ProcessName % prec PROC; But without any result. Thank you.

    Read the article

  • Operator precedence in scala

    - by Jeriho
    I like scala's propose of operator precedence but in some rare case unmodified rules may be inconvenient because you have restrictions in naming your methods. Is there in scala ways to define another rules for a class/file/etc? If not would it be resolved in future?

    Read the article

  • Specification Pattern and Boolean Operator Precedence

    - by Anders Nielsen
    In our project, we have implemented the Specification Pattern with boolean operators (see DDD p 274), like so: public abstract class Rule { public Rule and(Rule rule) { return new AndRule(this, rule); } public Rule or(Rule rule) { return new OrRule(this, rule); } public Rule not() { return new NotRule(this); } public abstract boolean isSatisfied(T obj); } class AndRule extends Rule { private Rule one; private Rule two; AndRule(Rule one, Rule two) { this.one = one; this.two = two; } public boolean isSatisfied(T obj) { return one.isSatisfied(obj) && two.isSatisfied(obj); } } class OrRule extends Rule { private Rule one; private Rule two; OrRule(Rule one, Rule two) { this.one = one; this.two = two; } public boolean isSatisfied(T obj) { return one.isSatisfied(obj) || two.isSatisfied(obj); } } class NotRule extends Rule { private Rule rule; NotRule(Rule obj) { this.rule = obj; } public boolean isSatisfied(T obj) { return !rule.isSatisfied(obj); } } Which permits a nice expressiveness of the rules using method-chaining, but it doesn't support the standard operator precedence rules of which can lead to subtle errors. The following rules are not equivalent: Rule<Car> isNiceCar = isRed.and(isConvertible).or(isFerrari); Rule<Car> isNiceCar2 = isFerrari.or(isRed).and(isConvertible); The rule isNiceCar2 is not satisfied if the car is not a convertible, which can be confusing since if they were booleans isRed && isConvertible || isFerrari would be equivalent to isFerrari || isRed && isConvertible I realize that they would be equivalent if we rewrote isNiceCar2 to be isFerrari.or(isRed.and(isConvertible)), but both are syntactically correct. The best solution we can come up with, is to outlaw the method-chaining, and use constructors instead: OR(isFerrari, AND(isConvertible, isRed)) Does anyone have a better suggestion?

    Read the article

  • How is precedence determined in C pointers?

    - by ankur.trapasiya
    I've come across two pointer declarations that I'm having trouble understanding. My understanding of precedence rules goes something like this: Operator Precedence Associativity (), [ ] 1 Left to Right *, identifier 2 Right to Left Data type 3 But even given this, I can't seem to figure out how to evaluate the following examples correctly: First example float * (* (*ptr)(int))(double **,char c) My evaluation: *(ptr) (int) *(*ptr)(int) *(*(*ptr)(int)) Then, double ** char c Second example unsigned **( * (*ptr) [5] ) (char const *,int *) *(ptr) [5] *(*ptr)[5] *(*(*ptr)[5]) **(*(*ptr)[5]) How should I read them?

    Read the article

  • SQL Logic Operator Precedence: And and Or

    - by nc
    Are the two statements below equivalent? SELECT [...] FROM [...] WHERE some_col in (1,2,3,4,5) AND some_other_expr and SELECT [...] FROM [...] WHERE some_col in (1,2,3) or some_col in (4,5) AND some_other_expr Is there some sort of truth table I could use to verify this? Thanks.

    Read the article

  • best practice on precedence of variable declaration and error handling in C

    - by guest
    is there an advantage in one of the following two approaches over the other? here it is first tested, whether fopen succeeds at all and then all the variable declarations take place, to ensure they are not carried out, since they mustn't have had to void func(void) { FILE *fd; if ((fd = fopen("blafoo", "+r")) == NULL ) { fprintf(stderr, "fopen() failed\n"); exit(EXIT_FAILURE); } int a, b, c; float d, e, f; /* variable declarations */ /* remaining code */ } this is just the opposite. all variable declarations take place, even if fopen fails void func(void) { FILE *fd; int a, b, c; float d, e, f; /* variable declarations */ if ((fd = fopen("blafoo", "+r")) == NULL ) { fprintf(stderr, "fopen() failed\n"); exit(EXIT_FAILURE); } /* remaining code */ } does the second approach produce any additional cost, when fopen fails? would love to hear your thoughts!

    Read the article

  • MySQL INSERT and SELECT Order of precedence

    - by Carlos Dubus
    Hi, if an INSERT and a SELECT are done simultaneously on a mysql table which one will go first? Example: Suppose "users" table row count is 0. Then this two queries are run at the same time (assume it's at the same mili/micro second): INSERT into users (id) values (1) and SELECT COUNT(*) from users Will the last query return 0 or 1?

    Read the article

  • Operation precedence on postgress

    - by user24691
    I have set new division on postgress pg_operator table because i want tath when is division by zero return 0. i have write this: create operator / ( procedure = zero_division, leftarg = double precision, rightarg = double precision); where zero_division is: CREATE OR REPLACE FUNCTION zero_division(double precision, double precision) RETURNS double precision AS 'select case when $2 = 0 then 0 else $1 / $2::real end;' LANGUAGE sql IMMUTABLE COST 100; when i run value/ 0 i get error of division.

    Read the article

  • Super+digit takes precedence over Ctrl+Super+digit

    - by Gauthier
    I use Ctrl+Super+digit` to switch workspace. I also use Super+digit to start programs that are pinned to the bar (unity default). The problem is that when I try to switch workspace, if I happen to press Super before Ctrl, Super+digit is executed as if Ctrl was never pressed although it is. How do I make sure that Ctrl+Super+digit is recognized as such, whatever the order in which Ctrl and Super were pressed?

    Read the article

  • SQL Server Data Type Precedence

    I am executing a simple query/stored procedure from my application against a large table and it's taking a long time to execute. The column I'm using in my WHERE clause is indexed and it's very selective. The search column is not wrapped in a function so that's not the issue. What could be going wrong? Schedule Azure backupsRed Gate’s Cloud Services makes it simple to create and schedule backups of your SQL Azure databases to Azure blob storage or Amazon S3. Try it for free today.

    Read the article

  • _default_ VirtualHost overlap on port 443, the first has precedence

    - by Mohit Jain
    I have two ruby on rails 3 applications running on same server, (ubuntu 10.04), both with SSL. Here is my apache config file: <VirtualHost *:80> ServerName example1.com DocumentRoot /home/me/example1/production/current/public </VirtualHost> <VirtualHost *:443> ServerName example1.com DocumentRoot /home/me/example1/production/current/public SSLEngine on SSLCertificateFile /home/me/example1/production/shared/example1.crt SSLCertificateKeyFile /home/me/example1/production/shared/example1.key SSLCertificateChainFile /home/me/example1/production/shared/gd_bundle.crt SSLProtocol -all +TLSv1 +SSLv3 SSLCipherSuite HIGH:MEDIUM:!aNULL:+SHA1:+MD5:+HIGH:+MEDIUM </VirtualHost> <VirtualHost *:80> ServerName example2.com DocumentRoot /home/me/example2/production/current/public </VirtualHost> <VirtualHost *:443> ServerName example2.com DocumentRoot /home/me/example2/production/current/public SSLEngine on SSLCertificateFile /home/me/example2/production/shared/iwanto.crt SSLCertificateKeyFile /home/me/example2/production/shared/iwanto.key SSLCertificateChainFile /home/me/example2/production/shared/gd_bundle.crt SSLProtocol -all +TLSv1 +SSLv3 SSLCipherSuite HIGH:MEDIUM:!aNULL:+SHA1:+MD5:+HIGH:+MEDIUM </VirtualHost> Whats the issue: On restarting my server it gives me some output like this: * Restarting web server apache2 [Sun Jun 17 17:57:49 2012] [warn] _default_ VirtualHost overlap on port 443, the first has precedence ... waiting [Sun Jun 17 17:57:50 2012] [warn] _default_ VirtualHost overlap on port 443, the first has precedence On googling why this issue is coming I got something like this: You cannot use name based virtual hosts with SSL because the SSL handshake (when the browser accepts the secure Web server's certificate) occurs before the HTTP request, which identifies the appropriate name based virtual host. If you plan to use name-based virtual hosts, remember that they only work with your non-secure Web server. But not able to figure out how to run two ssl application on same server. Can any one help me?

    Read the article

  • ubuntu ppa's and apt precedence

    - by Brad Robertson
    I'm trying to get the latest mplayer installed with vdpau support. Haven't had any luck so far. I found a PPA that says it works and I want to install it. I added the PPA to my apt.sources and did an update. I just wanted to know, how do I know that I'm now installing the mplayer package from the PPA, and not Ubuntu's standard repositories? From what I see I just install the same package using apt-get install mplayer. How do I know which mplayer I'm getting? Where do I specify what takes precedence?

    Read the article

  • Understanding evaluation of expressions containing '++' and '->' operators in C.

    - by Leif Ericson
    Consider this example: struct { int num; } s, *ps; s.num = 0; ps = &s; ++ps->num; printf("%d", s.num); /* Prints 1 */ It prints 1. So I understand that it is because according to operators precedence, -> is higher than ++, so the value ps->num (which is 0) is firstly fetched and then the ++ operator operates on it, so it increments it to 1. struct { int num; } s, *ps; s.num = 0; ps = &s; ps++->num; printf("%d", s.num); /* Prints 0 */ In this example I get 0 and I don't understand why; the explanation of the first example should be the same for this example. But it seems that this expression is evaluated as follows: At first, the operator ++ operates, and it operates on ps, so it increments it to the next struct. Only then -> operates and it does nothing because it just fetches the num field of the next struct and does nothing with it. But it contradicts the precedence of operators, which says that -> have higher precedence than ++. Can someone explain this behavior? Edit: After reading two answers which refer to a C++ precedence tables which indicate that a prefix ++/-- operators have lower precedence than ->, I did some googling and came up with this link that states that this rule applies also to C itself. It fits exactly and fully explains this behavior, but I must add that the table in this link contradicts a table in my own copy of K&R ANSI C. So if you have suggestions as to which source is correct I would like to know. Thanks.

    Read the article

  • Conversion constructor vs. conversion operator: precedence

    - by GRB
    Reading some questions here on SO about conversion operators and constructors got me thinking about the interaction between them, namely when there is an 'ambiguous' call. Consider the following code: class A; class B { public: B(){} B(const A&) //conversion constructor { cout << "called B's conversion constructor" << endl; } }; class A { public: operator B() //conversion operator { cout << "called A's conversion operator" << endl; return B(); } }; int main() { B b = A(); //what should be called here? apparently, A::operator B() return 0; } The above code displays "called A's conversion operator", meaning that the conversion operator is called as opposed to the constructor. If you remove/comment out the operator B() code from A, the compiler will happily switch over to using the constructor instead (with no other changes to the code). My questions are: Since the compiler doesn't consider B b = A(); to be an ambiguous call, there must be some type of precedence at work here. Where exactly is this precedence established? (a reference/quote from the C++ standard would be appreciated) From an object-oriented philosophical standpoint, is this the way the code should behave? Who knows more about how an A object should become a B object, A or B? According to C++, the answer is A -- is there anything in object-oriented practice that suggests this should be the case? To me personally, it would make sense either way, so I'm interested to know how the choice was made. Thanks in advance

    Read the article

  • Need to format character precedence in Strings.

    - by Christian
    I'm currently writing a Roman Numeral Converter for the fun of it. The problem works up to the aforementioned character precedence. Since Roman Numerals are not positional, i.e. III does not symbolize 1*whatever base^2 + 1*whatever base^1 + 1*whatever base^0. That of course makes it hard when somebody types in XIV and I need to make sure that the I is not added in this case, but rather subtracted. I'm not sure how to do this. What would be the best approach to tackle this? I have both the Roman Symbols and their respective decimal numbers stored in arrays: const char cRomanArray[] = "IVXLCDM"; const int romanArray[] = { 1, 5, 10, 50, 100, 500, 1000 }; so it wouldn't be too hard for me to brute-force the damn thing by simply checking the precedence within the array, i.e. if the symbol is smaller than the next symbol, i.e. in the exampe 'XIV' if 'I' is smaller than 'V', in which case it would be because I have ordered them in the array, then I could make it subtract the value instead of add. But this seems like a very ugly solution. Are there perhaps any better ones? I was thinking something along the lines of Regular Expressions maybe( forgive me if that sounds like a horrible idea, I haven't used RegExp yet, but it sounds like it could do what I need, and that's to determine the characters in a string.)

    Read the article

  • Should I use parentheses in logical statements even where not necessary?

    - by Jeff Bridgman
    Let's say I have a boolean condition a AND b OR c AND d and I'm using a language where AND has a higher order of operation precedent than OR. I could write this line of code: If (a AND b) OR (c AND d) Then ... But really, that's equivalent to: If a AND b OR c AND d Then ... Are there any arguments in for or against including the extraneous parentheses? Does practical experience suggest that it is worth including them for readability? Or is it a sign that a developer needs to really sit down and become confident in the basics of their language?

    Read the article

  • Built-in precedence in Expression Trees for math?

    - by jdk
    I'm unable to find the .NET FCL built-in concept of precedence to leverage while constructing Expression Trees. Ref System.Linq.Expressions Namespace. Is this something that must be handled manually in code, or is it somehow implicit and I'm not recognizing it (e.g. maybe through helper methods or classes)? I want to apply it to math operations to ensure 3 + 5 * 10 results in 53 instead of 80.

    Read the article

  • Seam IllegalStateException: Two components with the same name and precedence

    - by Anand
    Hi, When I run my seam application I get the following error Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener java.lang.IllegalStateException: Two components with the same name and precedence - component name: wizardController, component classes: package.WizardController, package.WizardController at org.jboss.seam.init.Initialization.addComponentDescriptor(Initialization.java:543) at org.jboss.seam.init.Initialization.installScannedComponentAndRoles(Initialization.java:809) at org.jboss.seam.init.Initialization.scanForComponents(Initialization.java:756) at org.jboss.seam.init.Initialization.init(Initialization.java:629) at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:35) I am not able to resolve this problem.

    Read the article

  • Built-in precedence in Expression Trees?

    - by jdk
    I'm unable to find the .NET FCL built-in concept of precedence to leverage while constructing Expression Trees. Ref System.Linq.Expressions Namespace. Is this something that must be handled manually in code, or is it somehow implicit and I'm not recognizing it? Maybe through helper methods or classes? I want to apply it to math operations to ensure 3 + 5 * 10 results in 53 instead of 80.

    Read the article

  • Logical operator AND having higher order of precedence than IN

    - by AspOnMyNet
    I’ve read that logical operator AND has higher order of precedence than logical operator IN, but that doesn’t make sense since if that was true, then wouldn’t in the following statement the AND condition got evaluated before the IN condition ( thus before IN operator would be able to check whether Released field equals to any of the values specified within parentheses ? SELECT Song, Released, Rating FROM Songs WHERE Released IN (1967, 1977, 1987) AND SongName = ’WTTJ’ thanx

    Read the article

  • Java Operator Precedence Comparison

    - by Andrew
    Does java have a built-in method to compare precedence of two operators? For example, if I have a char '/' and a char '+' is there a method I can call that compares the two and returns true/false if the first is greater than the second (e.g. true)?

    Read the article

  • Built-in precedence for Expression Trees?

    - by jdk
    I'm unable to find the .NET FCL built-in concept of precedence to leverage while constructing Expression Trees. Ref System.Linq.Expressions Namespace. Is this something that must be handled manually in code, or is it somehow implicit and I'm not recognizing it, maybe through helper methods or classes? I want to apply it to math operations to ensure 3 + 5 * 10 results in 53 instead of 80.

    Read the article

  • Passenger_wsgi.py given precedence over DirectoryIndex?

    - by Walkerneo
    I was having an issue with my site today, where apache wasn't serving index.php by default. I had moved passenger_wsgi.py to the directory above document root so that I could serve python files without having to use PassengerAppRoot in the .htaccess file. I wanted to do this because I set up a development sub-domain on the site, and I wanted to use a different passenger_wsgi for the two domains, but that meant having different .htaccess files for the different PassengerAppRoots. Is there a way to have passenger_wsgi.py where it was and still let apache serve the index.phps? edit: I'm sorry, I'm tired. I just realized that the way this probably works is that passenger_wsgi.py is handling the routing instead of apache.

    Read the article

1 2 3 4 5 6 7 8 9  | Next Page >