syntax

I don't like this... Is this cheating the language?

I have seen something like the following a couple times... and I hate it. Is this basically 'cheating' the language? Or.. would you consider this to be 'ok' because the IsNullOrEmpty is evaluated first, all the time? (We could argue whether or not a string should be NULL when it comes out of a function, but that isn't really the questio...

What is the equivalent for LOCK_ESCALATION = TABLE in SQL Server 2005?

I have a script that was generated in SQL Server 2008, but I need to execute it against a SQL Server 2005 database. What would an equivalent statement for the following be in SQL Server 2005? ALTER TABLE dbo.Event SET (LOCK_ESCALATION = TABLE) ...

syntax terminology

Does anyone know the term for this form of command-line syntax notation? For instance, when specifying command-line arguments: key[,alignment][:format] So that key is a required argument, and can be followed by a space and an alignment parameter, which can also be followed by a colon and a format. It's not BNF. Is there a name for ...

Easily access an array based on its dimensions

Lets say I have an array which has n dimensions. Now in order to access a slot you typically use: array [1][0] What if the number of dimensions are not known at compile-time, is there an easy access like: slot = "1,0" array [slot] // accessing 1,0 Which means I can also easily navigate back and forth slot += ",2" array [slo...

Dim X as New Y vs. Dim X as Y = New Y()

Duplicate Whats the difference between declaring as new and as something new something i Sad that I don't know this, but can anyone explain the difference between: Dim X as New Y and Dim X as Y = New Y() ...

Why is 2[myArray] valid C syntax?

Duplicate In C arrays why is this true? a[5] == 5[a] Given an array myArray[5] = { 0, 1, 2, 3, 4 }; an element can be accessed as 2[myArray] Why? When I see this expression I'm imagining C trying to access the pointer "2" and failing to add "myArray" pointer increments to dereference that address. What am I missing? ...

Conditional column for query based on other columns in MySQL

I'm pretty sure I've seen this somewhere, but I can't find the right terminology so I'm having trouble... Let's say I have a table with user info (let's also assume that it was created by someone who gets paid more than me, so modifying the schema is not an option.) Among the various columns of user info are columns for DOB and job titl...

Effects of the `extern` keyword on C functions

In C I did not notice any effect of the extern keyword used before function declaration. At first I thought that when defining extern int f(); in a single file forces you to implement it outside of the file's scope. However I found out that both: extern int f(); int f() {return 0;} and extern int f() {return 0;} compile just fine,...

Semantics of F# let statement with comma

I'm learning F#. I started by looking over the F# samples from Microsoft. I ran across this statement: let line1,line2 = use sr = System.IO.File.OpenText @"test.txt" let line1 = sr.ReadLine() let line2 = sr.ReadLine() (line1,line2) Can anyone explain this statement to me? What type is being defined here? A functio...

Semantics of F# statement

Can someone describe this F# expression to me? val augment: GameGrid -> points -> unit What does the val keyword mean? Is it true that usually type -> type indicates a function that returns the specified type? So does type -> type -> type indicate a function that returns a function that returns the specified type? ...

How do I create const arrays and calculated const values in C++ class?

I'm running into some compiler errors I don't understand. I'm pretty sure I'm doing something very wrong here but I don't know what. I would like all the world constants to be defined as belonging to the class. Notes: I'm only using classes as structs with attached members. I'm not following strict Object-Orriented Design on purpose....

how do i translate this Haskell to F#?

I'm trying to learn F# by translating some Haskell code I wrote a very long time ago, but I'm stuck! percent :: Int -> Int -> Float percent a b = (fromInt a / fromInt b) * 100 freqs :: String -> [Float] freqs ws = [percent (count x ws) (lowers ws) | x <- ['a' .. 'z']] I've managed this: let percent a b = (floa...

Why does the return keyword cause problems in my 'if block'?

The following code works fine: person = {:a=>:A, :b=>:B, :c=>:C} berson = {:a=>:A1, :b=>:B1, :c=>:C1} kerson = person.merge(berson) do | key, oldv, newv | if key == :a oldv elsif key == :b newv else key end end puts kerson.inspect but if I add the return keyword inside the "if block", I get an error: person = {:a=>:A, :b=>:B,...

In Java, can I define an integer constant in binary format?

Similar to how you can define an integer constant in hexadecimal or octal, can I do it in binary? I admit this is a really easy (and stupid) question. My google searches are coming up empty. ...

WHERE x IN (5) vs WHERE x = 5 ... why use IN?

Something I've noticed recently is people using IN where it seems kind of inappropriate. I'm feeling like I'm missing a trick - perhaps there are speed gains or something? This query: SELECT * FROM pages WHERE is_visible IN ($visibility) Why use that? Why not: SELECT * FROM pages WHERE is_visible = $visibility Sure, if it were thi...

Objective advantages of C-style syntax

There is a really big number of programming-languages that are heavily influenced by C-style syntax (curly-braced, semicola, etc.), maybe more than by any other syntactial style. And till this day, many modern and successful or even newly invented languages use this syntax - just think of Java, C++, C#, PHP, JavaScript, C, Perl etc. Are...

Which keyword of your language would you like to get rid of?

Programming languages vary a lot in the syntax they use. The syntax being a bunch of keywords is what we have to deal with in every language. But from the gut feeling not all of these keywords seem to be wisely chosen. One reason might be that a word is a keyword that you would want to use often in your code but you are not allowed to us...

Reference sheets

I needed sheets for quick references particular language syntax. I have found this that might help Any other suggestions? ...

ASP.Net VS ASP.Net MVC

Hello! Now this isn't a question as to which of the technologies is better, since they both have their relevant uses for different scenarios. My question is regarding the syntax of the two. How do their syntax's differ? ...

SQL query to join several columns

I'm trying to join some data together from 2 tables, but on several columns. here's an example: Source table ID | Desc| AAAA| BBBB| Table2 table ID | Text| ID1 | ID2 | ID3 | where ID1, ID2 and ID3 in Table2 are ID's from the Source table I'd like to do a query which yields the results: Table2.Text, Source.Desc(ID...