syntax

Build System for .NET with a Make/Rake-like syntax?

A Build system with .NET devs as its Primary Target Audience that is does not have an XML-only Syntax? ...

How to write 'if' without using 'then' or 'end' in Ruby

I've found three ways to write the same condition in Ruby: #1 if 1==1 puts "true" end #2 puts "true" if 1==1 #3 if 1==1 then puts "true" end Why can't I do this? #4 if 1==1 puts "true" I don't understand: (1) Why then and end are needed in #3, and, (2) Why I need to change the order to get #2 to work. Statement #4 seems...

Using Rhino Mocks how can I set a property of a parameter for a Mocked method

Using the new Rhino Mocks 3.5 Arrange/Act/Assert (AAA) Testing style, I'm having problems writing a test. I have a method that calls a method on a repository class. ActivateFoo, where my Foo object has an IsActive property. The result of the ActivateFoo object should change the property. Here is sample code: [TestMethod] public void ...

Powershell Add-Content

Hi Guys, So Im being a bit anal here but I cant get add-content to add both a string and the output of a cmdlet so it would look something like this; Add-content -path $logfile -value "This is my text"+(Get-Date) I realise I can just add another line to set a variable to the result of get-date but and then pass the variable into my ad...

if/else and if/elseif

If I have a statement block like this: if (/*condition here*/){ } else{ } or like this: if (/*condition here*/) else if (/*condition here*/) {} else if (/*condition here*/) {} What is the difference? It seems that with if/else, if part is for true state and the else part is for all other possible options (false). An else-if would...

What's the comma for in this code example?

cash = 100_000.00 sum = 0 cash += 1.00, sum while cash < 1_000_000.00 # underscores ignored I found the above example in a book "Learning Ruby" but using Ruby 1.9 it doesn't compile ("interpret"?) syntax error, unexpected ',', expecting $end What's the comma supposed to be doing after 1.00? Here's the full context of the example: ...

Unable to set the syntax of .txt file .tex in Emacs

How can you set the syntax of a .txt file .tex in Emacs? ...

Kernel.loop method requires 'do' - semicolon not allowed?

LOOP This works with do: x=0 loop do puts x; x+=1; break if x == 100 end but not with a semicolon: x=0 loop; puts x; x+=1; break if x == 100 end UNTIL However, this works with 'do': until x == 100 do puts x; x+=1 end and with a simicolon: until x == 100; puts x; x+=1 end With certain Ruby syntax I have a choice of u...

Does begin . . . end while denote a 'block'?

temp = 98.3 begin print "Your temperature is " + temp.to_s + " Fahrenheit. " puts "I think you're okay." temp += 0.1 end while temp < 98.6 In the above example, is everything between begin and end a block? I'm still confused what a block is. If you can't call it a block, what would you call that chunk of code between begin and end? I...

Fixing Lisp Syntax

Being a newbie to Lisp I'm wondering if the Lisp syntax could be "fixed"? Some people say the syntax in Lisp is one of its biggest strengths. I don't quite understand this. Isn't it possible to replace "obvious" parentheses with a combination of white spaces, new lines and indenting? Just like in Python? It looks to me like parenthe...

Backslashes in Single quoted strings vs. Double quoted strings in Ruby?

I'm a little confused about when to use single quoted strings versus double quoted strings. I've noticed that if I put a variable inside a single quoted string, it doesn't get interpreted. Also, if I use a newline character in a double quoted string, it causes the string to be displayed over two lines whereas in a single quoted string th...

Why does g++ compile this?

Recently, after being very tired, I wrote the following code: GLfloat* array = new GLfloat(x * y * z); Which, of course should have been: GLfloat* array = new GLfloat[x * y * z]; (Note the square brackets as opposed to the parenthesis.) As far as I know, the first form is not valid, but g++ compiled it. Sure, it spat out a complet...

How are floating point literals in C interpreted?

In a C program, when you write a floating point literal like 3.14159 is there standard interpretation or is it compiler or architecture dependent? Java is exceedingly clear about how floating point strings are interpreted, but when I read K&R or other C documentation the issue seems swept under the rug. ...

ASP.NET "special" tags

What is the official name for the "special" ASP.NET tags like this: <%# %> <%= %> <%@ %> <%$ %> I can't seem to figure out the conceptual or well known name for these, so I'm having trouble searching for more info. As a bonus, can anyone give me a quick rundown of all of the possible "special tags" and what each one of them does (or ...

C# 3.0 Autoproperties - whats the difference?

Hi in C# 3.0 What's the difference between the following? public class MyClass { public bool MyProperty; } public class MyClass { public bool MyProperty { get; set; } } Is it just semantics? ...

Is Erlang a concise language from a programmer's perspective?

Where would Erlang fall on the spectrum of conciseness between, say, Java/.net on the less concise end and Ruby/Python on the more concise end of the spectrum? I have an RSI problem so conciseness is particularly important to me for health reasons. ...

How to mix binding (<-) and assignment (let) in one line? (in Haskell)

This is about syntactic sugar in Haskell. A simple Haskell program: main = do args <- getArgs let first = head args print first I use binding in the first line (args <- getArgs) and a pure assignment in the second one (let first = ...). Is it possible to merge them together into a readable one-liner? I understand that I can rew...

Does this Ruby code look up identifiers or the values associated with them?

I've been trying to understand this example Ruby code from a blog entry which says it uses the symbols :DEFAULT, :say and :@message "to look up identifiers". But from what I can tell, it's not looking up the identifiers, but the values associated with those identifiers. I thought identifiers are names of variables, methods, etc. So the i...

Is there a speed difference between <?php echo $var; ?> and <?=$var?>?

Is there any speed difference between these two versions? <?php echo $var; ?> <?=$var?> Which do you recommend, and why? ...

Can I use AST transformations in Groovy to extend its syntax?

I have seen examples of how you can use the Groovy AST transformations to extend the language, e.g. to log before and after a method call as shown here. However, would it also be possible to use this framework to extend the syntax of the language itself? For instance, what if I wanted to be able to parse and transform the following into ...