syntax

Syntax for dereferencing a pointer in C (or C++)

I had a colleague check in code like this in C (syntax #1): (*(*(*p_member).p_member).p_member).member When I asked him why he didn't use -> (syntax #2): p_member->p_member->p_member->member he got really defensive stating that syntax #2 is more complicated than #1...I ended up changing his code because I had to modify it and cou...

What does the period do in this line of Fortran?

I am not sure what version of Fortran this is, but the line is: Term = F*F - 4.*E*G I know that it multiplies F by F and then subtracts something, but I don't know what the period after the 4 is doing there. ...

POSTGRESQL "IF" syntax error...

Hi guys, I'm new with postgresql, and already have my first problem.. Well, I wrote some code to understand how transactions work, following step by step the manual. To make it short, I've created 2 tables, user and movements: in the first one there are the name, email and credit columns, in the second the columns from, to, import. So...

Use Class Variables As Constants In Scala

I'm working to learn Scala--coming from a C++ background. I am trying to write a small class for a task tracking app I'm hacking together to help me to learn how to code Scala. This seems as if it should be simple but for some reason it's eluding me: package com.catenacci.tts class Task(val ID:Int, val Description:String) { val Empt...

how to select inner matches in lex

Hello, am new to lex and I wanna take all the matches specific to a regular expression for example in the following text : /* text text text text text */ text text /* text text text text text text text text */ i wanna choose the two matches between /* and */ but lex matches the whole outer match and doen't return the two! I u...

What is the difference in Perl when passing a variable in a regular expression between using $variable and ${variable}

I am reviewing some ClearCase triggers written in Perl. I have noticed that in some regular expressions, variables are passed either straighforwardly or with their names in curly brackets. For example, I have the following line of code in a trigger: if ($baseline !~ /^${component}_(|.*_)$phase\.\d+(|[a-z]|-\d+|${automateddigit})$/ && ...

Ruby: change each value in a hash with something like #collect for arrays?

Hi! I'd like to replace each value in a hash with value.some_method. For example in a simple hash {"a" => "b", "c" => "d"} every value should be .upcase-d so it looks like {"a" => "B", "c" => "D"}. I tried #collect and #map but always just get arrays back. Is there an 'elegant' way to do this? Thanks in advance, Adam Nonymous UPDAT...

What does the right arrow do in this code: "Ramaze.start :port => 80"

Ramaze.start :port => 80 If my understanding is correct, the line above is a method call in Ruby and you could also write it as: Ramaze.start(:port => 80) But in either case, what does it mean when you put the => character between the symbol :port and the number 80? Is that a way of creating a Hash? When the Ramaze.start method rec...

PHP MySQL syntax for inserting date,time

Hi, I am trying to insert to date,time fields using a php script but I am getting a syntax error. Can someone please tell me, where I am doing the mistake. Thanks fellows INSERT INTO calendar(event,from,to,day) VALUES ('".$_REQUEST['event']."', '".$_REQUEST['from_time']."', '".$_REQUEST['to_time']."', '".$_REQUEST['date_event']."') ...

What advantages does Sass provide over regular CSS?

I'm trying to decide on technologies for a presentation layer. I have heard Sass talked about enthusiastically but am resistant to learn something new without knowing why it's better than the alternative - in this case plain CSS. Any feedback on Sass would be welcome. Edit: This is also a good discussion on this: SASS: The Better, Mor...

How does an underscore in front of a variable in a cocoa objective-c class work?

I've seen in a few iPhone examples that attributes have used an underscore _ in front of the variable. Does anyone know what this means? or how it works? an interface file I'm using looks like: @interface MissionCell : UITableViewCell { Mission *_mission; UILabel *_missionName; } @property (nonatomic, retain) UILabel ...

What does += mean in Python?

I see code like this for example in Python: if cnt > 0 and len(aStr) > 1: while cnt > 0: aStr = aStr[1:]+aStr[0] cnt += 1 What does the += mean? ...

What does the following C++ struct syntax mean..

If I have a C++ struct, defining a 64bit data word such as.. struct SMyDataWord { int Name : 40; int Colour : 24; }; What does the : 40 syntax mean... does it mean that the first 40 bits are reserved for the Name and the remaining 24 bits for the Colour? This is how it appears to be being used, but I've not come across it be...

When do Ruby instance variables get set?

class Hello @hello = "hello" def display puts @hello end end h = Hello.new h.display I created the class above. It doesn't print anything out. I thought the instance variable @hello was set during the class declaration. But when I call the display method the output is 'nil'. What's the correct way to do this? ...

Is there a standard to easily show and hide content?

Do you toggle comments or slabs of code to quickly show or hide content? What are some common methods you use? Is there an accepted standard? Should some methods be avoided? ie could they be misinterpreted by some engines? Is there an alternative or better solution to this? Standard - This is what I use to cover most languages: CSS, J...

I've encountered this kind of syntax: var == "" ? "-" : var. Can somebody explain?

The code is this one: $vendors[] = array( "id" => $row['vendorID'], "name" => $row['name'] == "" ? "-" : $row['name'], "tel1" => $row['phone1'] == "" ? "-" : $row['phone1'], "tel2" => $row['phone2'] == "" ? "-" : $row['phone2'], "mail" => $row['email'] == "" ? "-" : $row['email'], "web" => $row['web'] == "" ? "-"...

Text-to-HTML converter for PHP

What text to HTML converter for PHP would you recommend? One of the examples would be Markdown, which is used here at SO. User just types some text into the text-box with some natural formatting: enters at the end of line, empty line at the end of paragraph, asterisk delimited bold text, etc. And this syntax is converted to HTML tags. ...

When were extended records introduced?

In Delphi 7, you a record was nothing more than a collection of data grouped into one location. In the last few versions, you've been able to add public and private members, methods, properties and constructors to them, treating them a lot more like objects. What version was this extended syntax introduced in? EDIT: In case anyone won...

class() vs. type() in Ruby

What's the difference between the class and type methods in Ruby? I've noticed that type works to find the type of some classes but not others. ...

C# Initialization Confusion!

int? test; try { test = (int?) Int32.Parse ("7"); } catch {} if (test == null) Console.WriteLine("test is null!"); else Console.WriteLine("test = {0}", test); I am have some code that does something VERY similar to this, same idea really... Creating a variable, trying to initialize it, then test to see if the initializa...