syntax

inline JSON syntax in PHP

PHP would be a lot cooler if you could write things like this: $array = [2, 3, 5]; $object = { "name" : "Harry", "age" : 23, "cats" : ["fluffy", "mittens", "whiskers"]}; but, I just spent a lot of time looking for an extension (even an experimental alpha or anything) adding json syntax to PHP but found nothing. Does anything like th...

What is the explicit keyword for in c++?

Possible Duplicate: What does the explicit keyword in C++ mean? explicit CImg(const char *const filename):_width(0),_height(0),_depth(0),_spectrum(0),_is_shared(false),_data(0) { assign(filename); } what's the difference with or without it? ...

Why can the code between ifndef/endif still get run here?

#define cimg_use_jpeg 2 #ifndef cimg_use_jpeg //code goes here #endif I really don't understand... ...

Expression for struct creation

Is is possible in C to create structs “inline”? typedef struct { int x; int y; } Point; Point f(int x) { Point retval = { .x = x, .y = x*x }; return retval; } Point g(int x) { return { .x = x, .y = x*x }; } f is valid, g not. Same applies to function calls: float distance(Point a, Point b) { return 0.0; } int ...

Why are SQL entries written in uppercase?

Possible Duplicate: Why should I capitalize my SQL keywords? hi, I'm pretty new to SQL, but i've noticed that writing SELECT * FROM column_name is almost always used when select * from column_name yields exactly the same result. I can't find anything online about this. Is this just a convention? Or will not using uppe...

Correct syntax for C pointer datatypes

I vaguely recall seeing this before in an answer to another question, but searching has failed to yield the answer. I can't recall what is the proper way to declare variables that are pointers. Is it: Type* instance; Or: Type *instance; Although I know both will compile in most cases, I believe there are some examples where it is ...

C# syntax - Colon after a variable name

Hey everyone, Quick question; I've recently upgraded to VS2010, and got the new version of ReSharper. Now, when ReSharper is giving me autocomplete options for a variable, it give me the option of <variableName>: What does the : stand for? For example; I have this: var productIds = new List<int>(inventoryItemsToProcess.Keys); And ...

What is this at the end of function ,...) in c++

Possible Duplicate: In a C function declaration, what does as the last parameter do? What does this mean ,...); it is written at the end of a function in a code i am debuging. like this void abc( int a, int b, ...); ...

What does "#include "myfile.php" do?

What's the meaning of the # symbol in the following line of php code: #include "myfile.php"; ...

jQuery syntax - when to use $ vs jQuery

What's difference between this two? $('#SPANID').html("Some Text"); jQuery('#SPANID').html("Some Text"); Is it something prototype vs jQuery? ...

Explain Iterator Syntax on Ruby on Rails

I started learning Ruby on Rails and found myself confounded by the syntax, so I had to read about somet of the Ruby syntax. I learned the syntax from http://www.cs.auckland.ac.nz/references/ruby/doc_bundle/Manual/man-1.4/syntax.html: method_call do [`|' expr...`|'] expr...end They call it an Iterator. I understand an iterator runs th...

Else clause on Python while statement

Hi everyone, I've noticed the following code is legal in Python. My question is why? Is there a specific reason? n = 5 while n != 0: print n n -= 1 else: print "what the..." Thanks. ...

Problem with OOP in PHP

I've got the following code: class the_class { private the_field; function the_class() { the_field = new other_class(); //has other_method() } function method() { $this->the_field->other_method(); //This doesn't seem to work } } Is there anything wrong with the syntax here? The method call always seems to return tr...

Languages with native / syntactical / inline graph support?

The graph is arguably the most versatile and valuable data structure of all. I can store single variables, lists, hashes etc., and of course graphs, with it. Given this, are there any languages that offer inline / native graph support and syntax? I can create variables, arrays, lists and hashes inline in Ruby, Python and Javascript, but...

Using AND, OR and NOT in Solr Query

HI, I am trying a solr query which is like this +field1:* AND (field2:1 OR field2:10) NOT(field3:value1 OR field3:value2) But field3 part of the query is not making any impact. It still brings record which has value1 or value2 in field3 Why is this ? ...

apply first of a list of functions in Clojure

if i have a list of functions: (def lst '(+ -)) and i wish to apply the first of that list (+) to a list of numbers, i would think its (apply (first lst) '(1 2 3 4)) but apparently i am wrong? syntax mistake i assume. how do i do this? PS: =>(first lst) + =>(apply (first lst) '(1 2 3 4)) 4 both return without...

VIM: Restore original foreground color for Normal highlight group

Howdy, Is there a way in vim to restore the terminal's original foreground color after changing it with the ':highlight Normal' command? For example, I'm using vim.exe 7.2 in a Windows Command Prompt. My Command Prompt has green text. When I start vim.exe, I can run the following command to change the text to red: :highlight Normal ct...

Using '\' in javascript to declare string occupying multiple lines

While looking through a 3rd party JavaScript API and example code I noticed the following declaration. Basically XML assigned to a string but they seem to split it up on multiple lines using '\', I was unaware this could be done in javascript. Could anyone provide some more details on how this works? Thanks. var PrimaryChannel = '<Chan...

Is this valid PHP syntax?

if ($var == ($var1 || $var2)) { ... } I am considering using this, but am ont sure if it is valid, and there doesn't seem to be somewhere to check. It seems logically consistent to me but am not sure, and I don't have something to test it on close by. If it is valid, what other mainstream languages support this sort of construct. ...

What is the difference between '__asm' and '__asm__'?

I am learning inline assembly in C. As far as I can tell, the only difference between __asm { ... }; and __asm__("..."); is that the first uses mov eax, var and the second uses movl %0, %%eax with :"=r" (var) at the end. Also, there are a lot less websites about the first. What other differences are there? ...