syntax

Is it possible to change emacs' regexp syntax?

I love emacs. I love regexs. I hate emacs' regex syntax - the need to escape grouping parens and braces, that you dont escape literal parens, the lack of predefined character classes, etc. Can I replace emacs' regex engine, or tweak some setting, so that when I use the Query-replace-regexp (or one of many other) feature I can use the s...

What is the => token called?

The => token is part of the C# 3.0 lambda syntax. My efforts to find the name of this token have failed so far. ...

hardcode byte array in C

I'm debugging a network application. I have to simulate some of the data exchanged in order for the application to work. In C++ you can du something like char* myArray = { 0x00, 0x11, 0x22 }; however I can't seem to find a C equivalent for this syntax. Basically I just want to fill an array with hard coded values ...

Natural Programming Language.... what would you like to see?

I am looking at writing a compiler and after I complete something in a "C" style I am looking at adapting it to other models. What are some syntactical constructs you would expect to see in a "natural" programming language? The target platform for this compiler will be the CLR and I am currently using Oslo+MGrammar for the lexer/pars...

In bash, how can I print the first n elements of a list?

In bash, how can I print the first n elements of a list? For example, the first 10 files in this list: FILES=$(ls) UPDATE: I forgot to say that I want to print the elements on one line, just like when you print the whole list with echo $FILES. ...

SQL left join vs multiple tables on FROM line?

Duplicate of: What’s the difference between just using multiple froms and joins? Most SQL dialects accept both the following queries: SELECT a.foo, b.foo FROM a, b WHERE a.x = b.x SELECT a.foo, b.foo FROM a LEFT JOIN b ON a.x = b.x Now obviously when you need an outer join, the second syntax is required. But when doing an inner joi...

How can I spot subtle Lisp syntax mistakes?

I'm a newbie playing around with Lisp (actually, Emacs Lisp). It's a lot of fun, except when I seem to run into the same syntax mistakes again and again. For instance, here's something I've encountered several times. I have some cond form, like (cond ((foo bar) (qux quux)) ((or corge (grault warg)) (fred) (t xyzzy))) ...

What is the use of the := syntax?

I'm a C# developer working on a VB.NET project, and VS keeps trying to get me to use the := thingie when I call a function with a ByRef parameter like so: While reader.Read() HydrateBookFromReader(reader:=???) . . . the HydrateBookFromReader function has the following signature: Public Function HydrateBookFromReader(ByRef reader As...

Python's 'with' statement versus 'with .. as'

Having just pulled my hair off because of a difference, I'd like to know what the difference really is in PYthon 2.5. I had two blocks of code (dbao.getConnection() returns a MySQLdb connection). conn = dbao.getConnection() with conn: # Do stuff And with dbao.getConnection() as conn: # Do stuff I thought these would have t...

Are some Functional Programming languages syntactically geared for better performance?

I hear about the manifold increase in productivity, while using certain languages (RoR). I have also heard about some VMs being more optimal than others (GHC?). Yet others are trying to optimize their language of choice by improving the underlying architecture (Unladen Swallow) However, while reading a paper ("SSA is functional programm...

Why is VB so popular?

To me, Visual Basic seems clumsy, ugly, error-prone, and difficult to read. I'll let others explain why. While VB.net has clearly been a huge leap forward for the language in terms of features, I still don't understand why anyone would choose to code in VB over, say, C#. However, I still see (what seems to be) the vast majority of comm...

DB2 Equivalent to SQL's GO?

I have written a DB2 query to do the following: Create a temp table Select from a monster query / insert into the temp table Select from the temp table / delete from old table Select from the temp table / insert into a different table In MSSQL, I am allowed to run the commands one after another as one long query. Failing that, I can ...

How can you write multiple statements in elisp 'if' statement?

In elisp, there is an 'if' case where I would like to perform many different things: (if condition (do-something) (do-something-else) ...) However, (do-something-else) is executed in the else-case only. How can you specify a block of instructions to execute? For example: (if condition (begin (do-something) ...

Undefined offset: 1

I'm getting this error related to my PHP error-handling function. Undefined offset: 1 Here's the error handling code: function customError($errno, $errstr) { error_log("Error: [$errno] $errstr",1,"[email protected]","From: [email protected]"); die(); } //set error handler set_error_handler("customError"); Can anyone help point ou...

bracket syntax for Ruby Hashes

Do these two statements pass the same type of argument (a Hash) to the new method? @seat = Seat.new(:flight_id => @flight.id) @seat = Seat.new({:flight_id => @flight.id}) Do the Hash brackets {} change anything in the second example? ...

Declaring arrays with data is easy in C# - how can I do it in VB?

Possible Duplicate: Anonymous class initialization in VB.Net Trying to convert examples like this from C# to VB.Net leaved me scratching my already bald head...: public ActionResult GridData(string sidx, string sord, int page, int rows) { var jsonData = new { total = 1, // we'll implement later page = page, recor...

Bash condition of the form - [ -n "${VAR:-x}" ] gets evaluated even though VAR is set

Hi all, I have written an if statement of the form: if [ -n "${VAR:-x}" ]; then #do something export VAR=#something fi My shell script calls this statement twice and surprisingly passes the condition twice. [hint (perhaps...): This exact code is repeated in a function in an included file. The if statement is first evaluated pr...

Ajax.request throws a syntax error, but returns the correct value

I have a bunch of Ajax requests that execute just fine, but I end up with a syntax error in my browser. Can anyone see what's wrong with my request below? function getName(refId) { var resp = ''; new Ajax.Request('/servlet/GetName', { method:'post', parameters: {'requestType':'ref', 'value':refI...

Rails collection_select search issue

I'm trying to display unique counties listed in my database in select box for a property database. I've figured out how to do this, but now I can't figure out how to access the selected value of the select. This mainly has do with the way the HTML select name is outputted. My form code, county is an attribute for my property model: ...

C# Generics - Syntax Help

The only C# generics explanations I can ever seem to locate go into the "List<T>" discussion and end there. I am looking for something a little more in-depth, specifically when dealing with <T> in method signatures -- I see some pretty wild syntax at times and am having trouble understanding why and when to use it. I feel like I could ...