syntax

Using elements of a constant array as cases in a switch statement

I'm attempting to map a set of key presses to a set of commands. Because I process the commands from several places, I'd like to set up a layer of abstraction between the keys and the commands so that if I change the underlying key mappings, I don't have to change very much code. My current attempt looks like this: // input.h enum LOG...

C/C++ comparison syntax

Hi all, I noticed for a while now the following syntax in some of our code: if( NULL == var){ //... } or if( 0 == var){ //... } and similar things. Can someone please explain why did the person who wrote this choose this notation? (instead of the common var == 0 way) Is it a matter of style, or does it somehow affect perfor...

Fortran: line to long / append line - but with text at the end?

I have a line of Fortran code, which includes some text. I'm changing the text, which makes the code line too long for Fortran, so I split it over two lines using 'a'. Was: IF (MYVAR .EQ. 1) THEN WRITE(iott,'(A) (A)') 'ABC=', SOMEVAR Changed to: IF (MYVAR .EQ. 1) THEN WRITE(iott,'(A) (A)') 'ABC DEF GHI JK a ' // 'L=', S...

jQuery - looking for a better selectors syntax

I've got HTML code that roughly looks like this: <li id="someid-11"> <img src="..." alt="alt" /> <h2><a href="somelink"> sometext </a> <span><a class="editcontent" href="?action=editme">Edit</a></span> </h2> <div id="11" class="content"> <!-- // content goes here --> <div class="bottom_of_entry"> </div> </li> I'm using the a.e...

What is the syntax for an Anonymous type in VB?

i am trying to set the htmlAttribute property but i cant figure out the correct syntax here is how it works in c# <%=Html.Password("myPassword", 50,"",new { style = "width:100px" })%><br /> what would be the vb.net version of new { style = "width:100px" } ? ...

What does * HTML Body mean in a css style sheet?

In a stylesheet i have: * HTML BODY { padding-right: 0px; padding-left: 0px; padding-bottom: 25px; padding-top: 190px; } * HTML #maincontent { width: 100%; height: 100%; } i know that a . means class and a # means applied to the id, but what does * HTML mean? ...

Update syntax for Access

I need to update a field (which is currently empty) based on a match with another table. This should be simple, but my syntax is wrong. In SQLServer 2005, the syntax would be UPDATE Facilities-NOID SET Facilities-NOID.ID = Facilities-ID.ID FROM Facilities-NOID, Facilities-ID WHERE [Facilities-ID].[Structure ID] = [Facilities-NOID].[S...

What does the []-esque decorator syntax in Python mean?

Here's a snippet of code from within TurboGears 1.0.6: [dispatch.generic(MultiorderGenericFunction)] def run_with_transaction(func, *args, **kw): pass I can't figure out how putting a list before a function definition can possibly affect it. In dispatch.generic's docstring, it mentions: Note that when using older Python versi...

JSON syntax for property names

What is the correct syntax to create objects in javascript that will work across the majority of web browsers (by that I mean : IE 6+, Firefox 2+, Opera 9+ ) Is this valid var a={ "class": "Person", "name": "William Shakespeare", "birthday": -12802392000000, "nickname": "Bill" } ; Or is this: var...

Groovy syntax explanation/resources

I started dabbling in groovy yesterday. There's an example on the groovy website that I understand but I would like to know more about why it works the way it does. What's confusing me is who[1..-1]. Is this like saying who[1..who.length()-1]? I can't find any documentation on this syntax. Are there any good groovy tutorials out ther...

Rosetta Stone: Lambda expressions

How are anonymous functions/lambda expressions expressed in various programming languages? Are the syntax and semantics especially useful or not useful in that language? Are there any programming languages for which true anonymous functions aren't possible? Like other Rosetta Stone questions, responses should start with the name of th...

How to constrain multiple generic types?

Here's a simple syntax question (I hope), I know how to constrain one generic type using the where clause, but how to constrain two generic types? Maybe the easiest way is to write down what my best guess as to the syntax was. public class GenericDaoGetByIdTests<TDao, TComponent> : BaseDaoTests where TDao : IDao<TComponent>, TCompon...

C++ Returning and Inserting a 2D array object

I am trying to return an array Data Member from one smaller 2D Array Object, and trying to insert the array into a larger 2D array object. But when attempting this, I came into two problems. First problem is that I want to return the name of the 2D array, but I do not know how to properly syntax to return 2D Array name. This is what my...

C++ Inserting 2D array Object into another

This problem is a continuation of a previous problem: http://stackoverflow.com/questions/402432/c-returning-and-inserting-a-2d-array-object and it is highly recommended to view the link to understand the following. I followed through Adam Rosenfield's answer and it solved the first two problems. However the last problem is not yet to ...

Ruby: More flexibility than Java/C#?

Is is that I'm a newbie learning Ruby, or does it really have more ways to write (the same) things than Java/C#? Also, if it is more flexible than Java, are there any linguistic features of Ruby that are generally not used to avoid confusion? Examples might be parallel assignment and all the different ways to write Strings, perhaps? No...

Is there a foreach in MATLAB? If so, how does it behave if the underlying data changes?

Is there a foreach structure in MATLAB? If so, what happens if the underlying data changes (i.e. if objects are added to the set)? ...

Delphi Syntax for TextMate

I exchanged emails with Marc-André Cournoyer of RefactorMyCode.com about supporting Delphi on his site. Since his site uses Ruby's UltraViolet to do syntax highlighting, and it uses TextMate syntaxes, he needs a Delphi syntax for TextMate. Turns out it has a Pascal syntax already, so it is 90% of the way there. Does anyone know where ...

Best way to work with an array of pointers in Objective-C?

I'm trying to mimic the following Java code: int[][] multi; // DIMENSIONS ARE UNKNOWN AT CREATION TIME // LATER ON... multi = new int[10][]; multi[5] = new int[20]; multi[5][11] = 66; // LATER ON... multi = null; // PROPER WAY OF FREEING EVERYTHING I've came out with the following Objective-C version: int* *multi; // multi = malloc(1...

Haskell parser error in where clause

What is wrong with rs definition in first where section? palindrome :: [a] -> [a] palindrome xs = con xs rs where con a b = rev (rev a []) b rs = rev xs -- here where rev [] rs = rs rev (x:xs) rs = rev xs (x:rs) I'm just learning haskell but its syntax rules confuse me. Error mes...

Weak typing in PHP: why use isset at all?

It seems like my code works to check for null if I do if ($tx) or if (isset($tx)) why would I do the second one when it's harder to write? ...