syntax

iphone sdk syntax

Hi All, This is probably a really basic syntax question, but I can't find the answer. Can anyone tell me what this expression means? objPoint.x = -objPoint.x; As a note, objPoint is a CGPoint Thanks! ...

Is this the standard behavior of PHP?

This works without warning: function test($a) { echo 1; } test(2, 1); This will cause warning: function test($a) { echo 1; } test(); If it's standard, any reason for this? ...

Does a begin-end block affect the performance of a conditional statement?

I am working with Delphi. Does it make any difference in performance if we write if condition in different ways? For example: if (condition) then someVar := someVal else someVar := someOtherVal; Or we can write: if (condition) then begin someVar := someVal; end else begin someVar := someOtherVal; end; I prefer the s...

C++: Struct initialization and maps

This works fine: #include <iostream> #include <map> using namespace std; struct Bar { int i; int f; }; int main() { map<int, Bar> m; Bar b; b.i = 1; b.f = 2; m[0] = b; } But if I want to make it a little more concise, I get errors: int main() { map<int, Bar> m; m[0] = {1, 2}; } Is th...

Can someone explain asp.net routing syntax to me?

I am dealing with this code in a Web Forms scenario: public static void RegisterRoutes(RouteCollection routes) { Route r = new Route("{*url}", new MyRouteHandler()); routes.Add(r); routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.IgnoreRoute("{resource}.gif/{*pathInfo}"); } Firstly, can anyone tell me w...

SQL Syntax error CREATE PROCEDURE AS EXTERNAL

Question: If I add IF not exists to a create procedure as external name statement, I get a syntax error... why? Both statements work fine if I run them separately... IF NOT EXISTS ( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'PriceSum') AND type in (N'P', N'PC') ) CREATE PROCEDURE PriceSum(@sum int OUTPUT) ...

nHibernate Join syntax error

I am doing my first nHibernate Join. In my function below, I want to return a list of records for the specified query. Normally my List type is the class representing the database table. In this case, since I am doing a join, I created a custom class that only contains the fields for the columns I am retrieving from the database. How...

Incorrect syntax near '-'

i am trying to run a query in another server and need to specify it in the select statement but the server name has got an '-' in it, like server-name. this is producing the error in the title. How can i fix it? ...

What does this line of C# code do?

int hour = DateTime.Now.Hour; ViewData["greeting"] = (hour < 12 ? "Good morning" : "Good afternoon"); Sorry for the noob question, but the ASP.NET MVC book I'm currently reading assumes that I already know C# (but I don't). I understand the first part - it assigns current date and time to the hour variable. But I am lost on the 2nd...

Dynamically add base class?

Let's say I have a base class defined as follows: class Form(object): class Meta: model = None method = 'POST' Now a developer comes a long and defines his subclass like: class SubForm(Form): class Meta: model = 'User' Now suddenly the method attribute is lost. How can I "get it back" without forcing...

Lua - multiple locals on one line?

Hi all, just a quick check... local var1, var2; Is var2 a local variable here? Or is only var1 a local? Thanks. ...

Syntax error in ALTER PROCEDURE in a DB update script

I have a script to update my database for a new release of my web app . In this update i need to alter a strored procedure. I have an ALTER PROCEDURE script that works fine when run on its own, however when I drop it into my update script and run it I get the errors "Incorrect syntax near the keyword 'PROCEDURE'." and "Must declare the s...

Python boolean expression and or

In python if you write something like foo==bar and spam or eggs python appears to return spam if the boolean statement is true and eggs otherwise. Could someone explain this behaviour? Why is the expression not being evaluated like one long boolean? Edit: Specifically, I'm trying to figure out the mechanism why 'spam' or 'eggs' is be...

Convert nested for-loops into single LINQ statement

Hi, can someone please help me turn this nested structure into a single LINQ statement? EventLog[] logs = EventLog.GetEventLogs(); for (int i = 0; i < logs.Length; i++) { if (logs[i].LogDisplayName.Equals("AAA")) { for (int j = 0; j < logs[i].Entries.Count; j++) ...

C++: strange behaviour with templates and #defines

I have the following definitions: template<typename T1, typename T2> class Test2 { public: static int hello() { return 0; } }; template<typename T> class Test1 { public: static int hello() { return 0; } }; #define VERIFY_R(call) { if (call == 0) printf("yea");} With these, I try to compile the following: VERIFY_R( Test1<int...

Tiling matrices in matlab

Hi, Here's an interesting question :) I have two "vectors of matrices" which I want to tile like the hankel function does for regular vertices. For example: Column Vector: 10 00 20 00 30 00 Row vector: 30 40 50 60 00 00 00 00 The resulting matrix needs to be: 10 20 30 40 00 00 00 00 20 30 40 50 00 00 00 00 30 40 50 60 00 00 ...

How to get 1st parameter in main() in C++?

Possible Duplicate: Pass arguments into C program from command line. mypro parameter When run like above,how to get the parameter in mypro's main() : #include <iostream> int main() { char* str = "default_parameter"; if(parameter_exists())str = parameter; ... } How to implement the pseudo code above? ...

Linux --help syntax

On a Linux system it is typical to type progname --help in order to view the help output for that program. After this you will see a description like: progname [SWITCHES] [FILES]... [ETC] My question is; is there a standardized syntax for his sort of (command-line use) documentation? In order to describe things like optional switches...

Solr - multifaceting syntax

I'm having a hard time constructing the URL for a query that has more than one multifacet. I'm following the sample here: http://www.craftyfella.com/2010/01/faceting-and-multifaceting-syntax-in.html For instance, take a look at the eBay screendump, how would the URL look like if you select 'Sony' and 'LG' in the 'Brand' section and the...

Vim object-select with syntax-aware text-objects

I just learned about the truly awesome object-select capabilities of vim. With the cursor within some "text object", a set of simple verbs can select or operate on the whole object. For example, with the cursor anywhere inside the quotes below (e.g. over the 'o'): print "Hello, world" ^ The command vi" will select the who...