syntax

Why can't non-partial active patterns be parameterized in F#?

The following F# code works as I expected, printing `Matched as 'A': let (|Char|_|) convf = function | LazyList.Nil -> None | LazyList.Cons (x, _) -> Some (convf x) let test = function | Char System.Char.ToUpper x -> printfn "Matched as %A" x | _ -> printfn "Didn't match" test (LazyList.of_list ['a']) However, if I c...

Regex for Matching Custom Syntax

Hello, I am trying to write a regular expression to match and split a custom variable syntax in C#. The idea here is a custom formatting of string values very similar to the .NET String.Format/{0} style of string formatting. For example the user would define a String format to be evaluated at runtime like so: D:\Path\{LanguageId}\{Pers...

Why is the C++ syntax so complicated?

I'm a novice at programming although I've been teaching myself Python for about a year and I studied C# some time ago. This month I started C++ programming courses at my university and I just have to ask; "why is the C++ code so complicated?" Writing "Hello world." in Python is as simple as "print 'Hello world.'" but in C++ it's: # in...

strange C macro syntax (#var)

What does the # symbol mean when used as a variable prefix in a #define macro? For example, #define my_setopt(x,y,z) _my_setopt(x, 0, config, #y, y, z) ...

"Official" syntax for referring to method of a class in Objective-C?

In Ruby, when referring to the "downcase" method of the class "String", I write String#downcase. When talking about the "new" class method, I write String.new. Is there something similar for Objective-C? ...

ruby framework method -> what's going on here?

def partial(template, *args) options = args.extract_options! options.merge!(:layout => false) if collection = options.delete(:collection) then collection.inject([]) do |buffer, member| buffer << erb(template, options.merge(:layout => false, :locals => {template.to_sym => member})) end.join("\n") else erb(t...

style and script tags in HTML body... why not?

[This is related to this question, but not since it's not about email.] In many cases -- especially when working with a CMS or someone else's framework, it's much easier to embed <style> tags and <script> tags in the <body> than in the <head>. This seems to work in IE6, IE7 (Windows), Firefox 3.x and Safari (OS X). Strictly speaking, ...

Is there a guide to the (somewhat) convoluted PowerShell syntax? Example with Biztalk

I should probably not ask a generic question with a specific example, but I have a hard time translating some basic commands from the PowerShell console to reusable functions and custom cmdlets. Is there a definitive guide to the syntax of PowerShell somewhere, with gotchas, hints and tips? For instance, I'm trying to create a function ...

Session.Item("Hello") vs Session("Hello")

Are there any advantages of using one over the other besides readability? ...

MySql and Wordpress query syntax

I'm trying to learn MySQL queries for use with Wordpress.... What I do know is this query, which gives all instances of the custom field "description" the value of "test" if the field is NULL UPDATE `wp_postmeta` SET `meta_value` = 'test' WHERE `meta_key` LIKE 'description' and `meta_value` is null What I need to do is change that so...

What's a more idiomatic Ruby way of writing this?

if params[:parent_type] == "Order" parent_id = nil else parent_id = params[:parent_id] end Would a Ruby person laugh at me for writing it this way? It doesn't seem particularly concise like some Ruby code I've seen. ...

What does colon mean in Perl?

What does the colon mean in the following Perl program? MAIN: { print "Hello\n"; } ...

What is this piece of Python code doing?

This following is a snippet of Python code I found that solves a mathematical problem. What exactly is it doing? I wasn't too sure what to Google for. x, y = x + 3 * y, 4 * x + 1 * y Is this a special Python syntax? ...

C# Arrays & Properties

I'm pretty darn new to C# and I can't figure out how to express something pretty simple. I have a 3D array that is private. I have no problem with the function that exposes the contents to read: public Terrain Tile(int x, int y, int z) { return .... but I also want an internal function that provides read/write access with a coordina...

making python 2.6 exception backward compatible

I have the following python code: try: pr.update() except ConfigurationException as e: returnString=e.line+' '+e.errormsg This works under python 2.6, but the "as e" syntax fails under previous versions. How can I resolved this? Or in other words, how do I catch user-defined exceptions (and use their instance variables) ...

php require function on linux server

does following this work on linux server? <? require 'foldername/header.php' ?> the above code is present in home.php. home.php is in folder foldername. ...

How do I perform update query with subquery in Access?

I want to port this SQL query, which works just fine on SQL Server, MySQL, and Oracle, to an Access database. How do I do that? Right now it prompts me for a Company_ID for some reason. Edit: I was getting the prompt because I forgot to first create the Company_ID column in VendorRegKeys. Now I am getting error "Operation must use an...

c++ template syntax error

Hi all; My C++ is a little rusty having worked in Java and C# for the last half dozen years. I've got a stupid little error that I just cannot figure out. I've pared the code down as much as possible. #include <list> template<class T> class Subscriber { virtual void published( T t ) = 0; }; template <class T> class PubSub { priva...

Java For-Each Loop : Sort order

Does a java for-each loop guarantee that the elements will be presented in order if invoked on a list? In my tests it does seem to, but I can't seem to find this explicitly mentioned in any documentation List<Integer> myList;// [1,2,3,4] for (Integer i : myList) { System.out.println(i.intValue()); } #output 1,2,3,4 ...

Opensource project's php syntax

Hi guys. When working with open source project (like wordpress, drupal, joomla) i always find in the php pages a syntax like (this is an example from drupal): <?php if ($linked_site_logo or $linked_site_name): ?> <?php if ($title): ?> <div class="logo-site-name"><strong> <?php if ($linked_site_logo): ?><span id="logo"><?php...