syntax

ANTLR C grammar, optional init_declarator_list?

Hello, In the ANSI C grammar for ANTLR v3 ( http://antlr.org/grammar/1153358328744/C.g ), how can init_declarator_list be optional in rule declaration ? Instead of: | declaration_specifiers init_declarator_list? ';' -I would say: | declaration_specifiers init_declarator_list ';' What part of the C standard allows statements like...

C#: Easy access to the member of a singleton ICollection<> ?

I have an ICollection that I know will only ever have one member. Currently, I loop through it, knowing the loop will only ever run once, to grab the value. Is there a cleaner way to do this? I could alter the persistentState object to return single values, but that would complicate the rest of the interface. It's grabbing data from XML...

C#: Union of two ICollections? (equivlaent of Java's addAll())

I have two ICollections of which I would like to take the union. Currently, I'm doing this with a foreach loop, but that feels verbose and hideous. What is the C# equivalent of Java's addAll()? Example of this problem: ICollection<IDictionary<string, string>> result = new HashSet<IDictionary<string, string>>(); ...

What's the u prefix in a python string

Like in: u'Hello' My guess is that it indicates "unicode", is it correct? If so, since when is it available? ...

Where To find online PHP/CSS Syntax Generator ?

i would like to learn how to make PHP/CSS syntax generator. i assume this going to be fun and all. Is there any open source PHP/CSS syntax generator ? Or at least, where the best syntax generator available in internet based on your experience ? ...

Do I need to release the temp Object from this example?

-(IBAction) testTemp: (id) sender{ id tempObj; tempObj = otherObject; //the otherObject will be released in dealloc method; [tempObj doSomething]; } As you can see, I use the tempObj for temp use. I won't use it after the user quit this method, should I need to release the tempObj? and why? ...

Difference between char *foo vs (char *)foo in Objective-C

What is the difference between char *foo and (char *) foo in Objective-C? Here is an example for both scenarios: 1. @interface Worker: NSObject { char *foo; } 2. - initWithName:(char *)foo ...

Nested dereferencing arrows in Perl: to omit or not to omit?

In Perl, when you have a nested data structure, it is permissible to omit de-referencing arrows to 2d and more level of nesting. In other words, the following two syntaxes are identical: my $hash_ref = { 1 => [ 11, 12, 13 ], 3 => [31, 32] }; my $elem1 = $hash_ref->{1}->[1]; my $elem2 = $hash_ref->{1}[1]; # exactly the same as above ...

PHP shorthand syntax

I've just came across this on GitHub. ($config === NULL) and $config = Kohana::config('email'); Is that the equivalent of if ($config === NULL) { $config = Kohana::config('email'); } Is this commonplace? Would I expect other developers looking at my code if I used that first way to instantly know what it was doing? ...

VBA: Difference in two ways of declaring a new object? (Trying to understand why my solution works)

I was creating a new object within a loop, and adding that object to a collection; but when I read back the collection after, it was always filled entirely with the last object I had added. I've come up with two ways around this, but I simply do not understand why my initial implementation was wrong. Original: Dim oItem As Variant Dim ...

What is wrong with my SQL syntax for an UPDATE with a JOIN?

I have two tables, related by a common key. So TableA has key AID and value Name and TableB has keys AID, BID and values Name, Value: AID Name 74 Alpha AID BID Name Value 74 4 Beta Brilliance I would like to update the TableB Value here from Brilliance to Barmy, using just the Name fields. I thought I could do it via an UPDATE ...

Anonymous recursive PHP functions.

Is it possible to have a PHP function that is both recursive and anonymous? This is my attempt to get it to work, but it doesn't pass in the function name. $factorial = function( $n ) use ( $factorial ) { if( $n == 1 ) return 1; return $factorial( $n - 1 ) * $n; }; print $factorial( 5 ); I'm also aware that this is a bad way t...

What is the pro and cons using Heredoc Notation in your PHP?

I've never seen something like this before. So, it's confusing me for a while. But now I understand and use it sometimes. So, after brief experience, can anybody tell me what is the pro and cons using Heredoc Notation in your PHP? $stringval = <<<MYHEREDOC just creating variable here. nothing more. MYHEREDOC; Personally, how do y...

VIM: created syntax not showing up?

HI people I recently changed to VIM for coding in C. I'd like to hightlight the operators +-<=& ... etc I searched in google how should i do it, and i found the answer in this website: I was suppose to do something like: syntax match Operadores /[][><()&!|+*={}-]/ hi Operadores guifg=#000000 gui=BOLD Those characters were supposed ...

Getting mysql syntax error and cant find source

I have function that updates log table. function wslog($userID, $log, $where) { safe_query("INSERT INTO ".PREFIX."log ( time, userID, log, where ) values( '".time()."', '".$userID."', '".$log."', '".$where."' ) "); } And I have this php code: wslog($userID, 'server|'.mysql_insert_id().'', 'servers'); But I keep getting syntax e...

What's "@Override" there for in java?

public class Animal { public void eat() { System.out.println("I eat like a generic Animal."); } } public class Wolf extends Animal { @Override public void eat() { System.out.println("I eat like a wolf!"); } } Does @Override actually have some functionality or it's just kinda comment? ...

meaning of '+='

I'm confused with the syntax of C#: what is the use of "+="? ...

Within an aray of objects can one create a new instance of an object at an index?

Here's the sample code: class TestAO { int[] x; public TestAO () { this.x = new int[5] ; for (int i = 0; i<x.length; i++) x[i] = i; } public static void main (String[]arg) { TestAO a = new TestAO (); System.out.println (a) ; TestAO c = new TestAO ...

Drools Rules: How can I use a method on "when" section?

Hi, I need to execute a method on "when" section of a DSLR file and I´m not sure if it´s possible. Example: rule "WNPRules_10" when $reminder:Reminder(source == "HMI") $user:User(isInAgeRange("30-100")==true) Reminder(clickPercentual >= 10) User(haveAtLeastOptIns("1,2,3,4") == true) then $reminder.setPriority(1);...

What's the prefix for binary in PHP?

It's neither 0x nor 0,what's it?Is there? ...