syntax

Ocaml Syntax Error

I'm using an implementation of lazy lists where the type can be either Nil or Cons (value, thunk), where thunk is a function from unit to the rest of the list. I'm trying to write a function cross, which would function as List.combine does. Unfortunately, I'm having syntax errors. open Sequence;; let rec (cross : 'a Sequence.t -> '...

How to copy code and paste in Rich Text Format with syntax highlighting?

I want to ability to select code from my program such as dreamweaver or visual studio and then paste the code into a word file or my favourite work processor and have the syntax highlighted as well. Is there a website that can provide this service with the ability to highlight syntax from various languages? ...

MySQL Syntax for setting Default Date

How can we set element to some default date in mysql ? In oracle we would do something like start_date DATE DEFAULT to__date('01011900','DDMMYYYY') mutation_date_time DATE DEFAULT SYSDATE CONSTRAINT entity_specification UNIQUE(external_name, start_date_time, end_date_time)) Also do we have any site or resource where we can get ...

Close statement with ; or not?

PHP allows me to: Hello, my name is <?php echo $name ?>, and stuff. Is that okay to do instead of Hello, my name is <?php echo $name; ?>, and stuff. I know the <?= ?> is being taken away, is this another one of those shortcuts to be killed? ...

php mysql query syntax question regarding ""'s

Forgive me, I'm a beginner. The following code returns a parse error: $query = "INSERT INTO scenario_needgames VALUES ("$id", "Battle of the Bulge")"; the query builder in phpMyAdmin gave me this slightly modified string that works: $query = "INSERT INTO scenario_needgames VALUES (\"$id\" , \"Battle of the Bulge\");"; but I'm confu...

JQuery, new JS function syntax

Can someone explain me the syntax below line 1? I am OK with js and function references, but this code looks a bit confusing. E.g. is it function declaration and execution? jQuery.noConflict(); (function($) { $(function() { // more code using $ as alias to jQuery }); })(jQuery); // other code using $ as an alias to the other li...

C++ - syntax for defining/instantiating strings

I am very new to C++ and still trying to learn syntax and best practices. I've defined a method with a single parameter: void foo(const std::string& name) 1) Is this a proper parameter declaration for a function that will be taking in a string defined by the user in, for example, a main method? 2) If this is proper/recommended synt...

Javascript, refer to a variable using a string containing it's name?

Is there a way to refer to a Javascript variable with a string that contains its name? example: var myText = 'hello world!'; var someString = 'myText'; //how to output myText value using someString? ...

Perl syntax error

See also SO 1664677 I get this error 2: Syntax error: "(" unexpected when I run this script -- all help is very appreciated #!/usr/bin/perl use Digest::MD5 qw(md5_hex); printf "Usage : keygen.pl e-mail key-id\ne-mail : the one you provided\nkey-id : provided by hcf/hsfconfig\n"; $pad = pack("H2048", "00000000963007772c610eeeba510...

This is useful but I'm not sure why it works

protected override Boolean IsValid(String propertyValue) { return !String.IsNullOrEmpty(propertyValue) && propertyValue.Trim().Length > 0; } This C# validation method does exactly what I want, but I wasn't aware that you could use expression short-circuiting like this. When propertyValue is null, doesn't execution still need to ev...

Help me improve this Erlang?

So I'm really interested in Erlang. I can't find an excuse to use it for anything big, but I try to use it for toy problems from time to time. Right now, I'm implementing a Roman Numeral translator. I'm just doing the "to" part for now, and I'm finding the code is awfully repetitive. It works like a charm, but, well, just look at it:...

What does ** operator do in Python?

What does this mean in python: sock.recvfrom(2**16) I know what sock is and I get the jest of recvfrom function, but what the hell is 2**16? ...

What is this syntax?

i = 1, 2, 3, 4, 5; this actually assigns 1 to i. I wonder if this type of assignment is actually useful somewhere? Do you know some application of this syntax? ...

Difference between these two syntaxes

type IFooable = abstract Foo : int -> int type IFooable2 = abstract Foo : a : int -> int type MyClass() = interface IFooable2 with member this.Foo(b) = 7 What is the difference between IFooable and IFooable2 ? Are they equivalent ? What is the purpose of it in the case of my example ? When to use it ? ...

PHP5: const vs static

In PHP5, what is the difference between using const and static? When is each appropriate? And what role does public, protected and private play - if any. ...

Using -> instead of direct function call

In some classes I see a call to a function is like: $this->ClearError(); When the function is residing in that class itself. How is the above approach different from a direct function call like: return ClearError(); ...

Python-equivalent of short-form "if" in C++

Is there a way to write this C/C++ code in Python? a = (b == true ? "123" : "456" ) Thanks so much! ...

Why Java language does not offer a way to declare getters and setters of a given "field" through annotations ?

I actually happily design and develop JEE Applications for quite 9 years, but I realized recently that as time goes by, I feel more and more fed up of dragging all these ugly bean classes with their bunch of getters and setters. Considering a basic bean like this : public class MyBean { // needs getter AND setter private int m...

PHP DomDocument XML Load with Broken XML Data

Hi, How do you deal with broken data in XML files? For example, if I had <text>Some &improper; text here.</text> I'm trying to do: $doc = new DOMDocument(); $doc->validateOnParse = false; $doc->formatOutput = false; $doc->load(...xml'); and it fails miserably, because there's an unknown entity. Note, I can't use CDATA due to t...

Is it possible to execute a "C" statement without a semicolon

Post an example to execute a "C" statement without semicolon( ; ) ...