syntax

Is there any difference between `new object()` and `new {}` in c#?

in c#, var x = new {}; declares an anonymous type with no properties. Is this any different from var x = new object(); ? ...

Java syntax question: <O> O accept(ObjectVisitorEx<O> visitor)

Naive question about Java syntax. What does <T> T accept(ObjectVisitorEx<T> visitor); mean? What would be the C# equivalent? ...

SQL Syntax -- Group By ... Custom Aggregate Functionality?

I've got a situation like this: Table: FunTable ItemKey.....ItemName.....ItemPriceEffectiveDate....ItemPrice 11.....ItemA.....6/6/2009.....$500 12.....ItemA.....6/15/2009.....$550 13.....ItemA.....9/9/2009.....$450 14.....ItemB.....3/9/2009.....$150 15.....ItemB.....9/9/2009.....$350 I need to do the following: Select   ItemName as It...

What is the recommended way of writing anonymous functions in C#?

var seq = Enumerable.Range(1, 10).Reverse(); var sort1 = seq.OrderBy(i => i); var sort2 = seq.OrderBy(delegate(int i) { return i; }); i think sort2 is more explicit but sort 1 is shorter. besides that, i don't really know the difference. what is the recommended way of doing this? ...

Java: Syntax and meaning behind "[B@1ef9157"? Binary/Address?

Hey, I'm trying to figure out what the [B@ prefix means in java. They come out when I attempt to print byte arrays. However, byte arrays of size 32 and size 4 are identical in length. Always "[@B1234567". What is this? Also, they have the property of only printing hex values. I know it can't just be a binary print because random ex...

Spy++-like tool for OpenGL render trees

Hi, is anybody here aware of a Spy++-like tool which lets me visualize the object tree of graphical elements in an OpenGL scene? If possible (Spy++ lets you do this), it would be great if the tool didn't require support being built into the application. I'm not too familiar with OpenGL yet, but maybe what I'm after is a view on the tre...

What's the different between "2*2" and "2**2" in Python?

What is the difference between the following codes? code1 var=2**2*3 code2 var2=2*2*3 I see no difference. This raises the following question. Why is the code1 used if we can use code2? ...

Unable to understand a line of Python code exactly

Alex's answer has the following line when translated to English print "%2d. %8.2f %8.2f %8.2f" % ( i, payment, interest, monthPayment) I am unsure about the line "%2d. %8.2f %8.2f %8.2f" % #Why do we need the last % here? It seems to mean the following apply %2d. to i apply %8.2f to payment apply %8.2f to ...

Is my jQuery syntax wrong here?

Hey everyone, I am learning jQuery and I'm finding that this code is not working: <script type="text/javascript"> $(document).ready( /* Navigtion Stuff */ function(){ $('.menu ul').hover( function(){ $(this).parent().addClass("active"); }, function(){ $(this).par...

Unable to set syntax highlighting automatically in Vim

I have the following in my .vimrc syntax on filetype plugin indent on # Thanks to Jeremy I run vim ~/.vimrc I get the right syntax highlighting. I source many files in my .vimrc. My .vimrc is a like a roadmap for me where I navigate by CTRL-W f The problem occurs when I navigate to a file which I have sourced: no colors. ...

simple php problem

OK, so here's the snippet: // start rememberMe $cookie_name = 'db_auth'; $cookie_time = (3600 * 24 * 30); // 30 days // check to see if user checked box if ($remember == 1) { setcookie ($cookie_name, 'username='.$username., time() + $cookie_time); } For some reason it breaks and I can't see why. I...

MS Access Query Syntax Error in FROM

This is for an assignment... I am to Write SQL out to display Customer's Last name, order date, product ID, fabric of the product, quantity ordered, and unit price. This must be a 4-table join and must user INNERJOIN even if where can be used. These are the tables involved. Cus (CID, Last, First, Phone) Orders (OrdID, OrdDate, ShipD...

What does `@` mean in Python?

like @login_required? ...

How to use Fortran compilers to parse-check or pretty print source files?

Is there a way to tell ifort or gfortran to just try to parse a source file (no include following, no compilation, no linking, etc) to tell us whether they find the syntax of the file acceptable / valid for a given Fortran version (77, 90, 95, ...) or at least valid at all? I'm working on a piece of software that will parse and analyze ...

OCL Syntax Checker

Hello, I have been looking for an existing open-source syntax-checker for the Object Constraint Language (OCL). I intend to extend the syntax-checker with additional functionality not present in the OCL standard to be more applicable to my usage with entity-relationship diagrams. However, most of the projects I have found are based on t...

Min character length, strlen?

if (strlen($comment > 2)) { Ok, so I only want to exec this if $comment consist of more than 2 characters I believe strlen should do this, but it doesn't. Am I using it wrong? ...

Why do we use "type * var" instead of "type & var" when defining a pointer?

I'm relatively new to C++ (about one year of experience, on and off). I'm curious about what led to the decision of type * name as the syntax for defining pointers. It seems to me that the syntax should be type & name as the & symbol is used everywhere else in code to refer to the variable's memory address. So, to use the traditional ...

PHP - Returning the last line in a file?

I'm guessing it's fgets, but I can't find the specific syntax. I'm trying to read out (in a string I'm thinking is easier) the last line added to a log file. ...

Unable to understand a statement about customizing Python's Macro Syntax

Cody has been building a Pythonic Macro Syntax. He says These macros allow you to define completely custom syntax, from new constructs to new operators. There's no facility for doing this in Python as it stands. I am not sure what he means by new constructs to new operators: Does he prefer to binary operators such as +, -...

Is it possible to turn off support for "and" / "or" boolean operator usage in gcc?

GCC seems to allow "and" / "or" to be used instead of "&&" / "||" in C++ code; however, as I expected, many compilers (notably MSVC 7) do not support this. The fact that GCC allows this has caused some annoyances for us in that we have different developers working on the same code base on multiple platforms and occasionally, these "error...