language-features

C# -Interview Question Anonymous Type

Recently i was asked to prove the power of C# 3.0 in a single line( might be tricky) i wrote new int[] { 1, 2, 3 }.Union(new int[]{10,23,45}). ToList().ForEach(x => Console.WriteLine(x)); and explained you can have (i) anonymous array (ii) extension method (iii)lambda and closure all in a single line.I got spot offer. But..... The ...

Can you do Logic Programming in Scala?

I read somewhere that Pattern Matching like that supported by the match/case feature in Scala was actually borrowed from Logic languages like Prolog. Can you use Scala to elegantly solve problems like the Connected Graph problem? e.g. https://www.csupomona.edu/~jrfisher/www/prolog_tutorial/2_15.html ...

How to automatically run in the background?

I'm not sure that it's not implemented yet, I hope that it is. But I know that in .Net programmers should manually run time-consuming task in the background thread. So every time we handle some UI event and we understand that this will take some time we also understand that this will hang UI thread and our application. And then we make ...

Managing multiple .NET languages in a web application

I am part of a development team building a new ASP.NET 3.5 web application. Two of us are C# coders, and the other is a VB.NET coder. I know that we can mix languages on a per-project basis, and one can build classes in one language that inherit from classes written in the other language in a different project (which we are already doin...

Interface member name conflicts in ActionScript 3

I am trying to create an ActionScript 3 class that implements two interfaces. The interfaces contain member functions with different signatures but the same name: public interface IFoo { function doStuff(input:int):void; } public interface IBar { function doStuff(input1:String, input2:Number):void; } public class FooBar implem...

Scala puts precedence on implicit conversion over "natural" operations... Why? Is this a bug? Or am I doing something wrong?

This simple test, of course, works as expected: scala> var b = 2 b: Int = 2 scala> b += 1 scala> b res3: Int = 3 Now I bring this into scope: class A(var x: Int) { def +=(y:Int) { this.x += y } } implicit def int2A(i:Int) : A = new A(i) I'm defining a new class and a += operation on it, and a convenient implicit...

Call/Return feature of classic C++(C with Classes), what modern languages have it?

Hi, On page 57 of The Design and Evolution of C++, Dr. Stroustrup talks about a feature that was initially part of C with Classes, but it isn't part of modern C++(standard C++). The feature is called call/return. This is an example: class myclass { call() { /* do something before each call to a function. */ } return() { /* do somet...

What is the difference between a strongly typed language and a statically typed language?

And does one imply the other? Thank you! ...

Appropriate high level language to deal with binary data

Hi, I need to write a small tool that parses a textual input and generates some binary encoded data. I would prefer to stay away from C and the like, in favour of a higher level, (optionally) safer, more expressive and faster to develop language. My language of choice for this kind of tasks usually is Python, but for this case dealing ...

C: 8x8 -> 16 bit multiply precision guaranteed by integer promotions?

I'm trying to figure out if the C Standard (C90, though I'm working off Derek Jones' annotated C99 book) guarantees that I will not lose precision multiplying two unsigned 8-bit values and storing to a 16-bit result. An example statement is as follows: unsigned char foo; unsigned int foo_u16 = foo * 10; Our Keil 8051 compiler (v7.50 ...

Array/list vs Dictionary (why we have them at first place)

To me they are both same and that is why i am wondering why we have dictionary data structure when we can do everything with arrays/list? What is so fancy in dictionaries? ...

Beginner question: What is binding?

Hi, I was trying to understand the difference between early and late binding, and in the process realized that the concept of binding is nebulous to me. I think I understand that it relates to the way data-as-a-word-of-memory is linked to type-as-a-set-of-language-features but I am not sure those are the right concepts. Also, how does...

Are Scala "continuations" just a funky syntax for defining and using Callback Functions?

And I mean that in the same sense that a C/Java for is just a funky syntax for a while loop. I still remember when first learning about the for loop in C, the mental effort that had to go into understanding the execution sequence of the three control expressions relative to the loop statement. Seems to me the same sort of effort has to ...

How to define a ternary operator in Scala which preserves leading tokens?

I'm writing a code generator which produces Scala output. I need to emulate a ternary operator in such a way that the tokens leading up to '?' remain intact. e.g. convert the expression c ? p : q to c something. The simple if(c) p else q fails my criteria, as it requires putting if( before c. My first attempt (still using c/p/q as abo...

Why is this Scala example of implicit parameter not working?

simple REPL test... def g(a:Int)(implicit b:Int) = {a+b} Why do neither of these attempted usages work? 1. scala> class A { var b:Int =8; var c = g(2) } :6: error: could not find implicit value for parameter b: Int class A { var b:Int =8; var c = g(2) } 2. scala> class A(var b:Int) { var c = g(2) } :6: error: could no...

What's the new way to iterate over a Java Map in Scala 2.8.0?

How does scala.collection.JavaConversions supercede the answers given here: http://stackoverflow.com/questions/495741/iterating-over-java-collections-in-scala (doesn't work because the "jcl" package is gone) and here http://www.eishay.com/2009/05/iterating-over-map-with-scala.html (doesn't work me in a complicated test which I'l...

Programming Constructs History

Let us research and trace back the origins of language constructs. For example: Constructs Introduced from LISP If-Else Block :"The ubiquitous if-then-else structure, now taken for granted as an essential element of any programming language, was invented by McCarthy for use in Lisp, where it saw its first appearance in a more gener...

C#4 features usable while targetting .net 3.5

Possible Duplicate: Is there a list of changes for C#4.0 that work in .Net 3.5? Is there a list of features of C#4 that don't require .NET 4.0? I discovered somewhat on accident that named and and optional parameters work even when targetting .NET 3.5 and I wonder what other C# 4 features I can use. I did a brief search and ...

Why scala not allowing '$' identifier in case statement?

this works as expected scala> 3 match { case x:Int => 2*x } res1: Int = 6 why does this fail? scala> 3 match { case $x:Int => 2*$x } :1: error: '=>' expected but ':' found. 3 match { case $x:Int => 2*$x } ^ scala> 3 match { case `$x`:Int => 2*$x } :1: error: '=>' expected but ':' found. 3 matc...

Cross-Platform Language + GUI Toolkit for Prototyping Multimedia Applications

I'm looking for a language + GUI toolkit for rapidly prototyping utility applications for multimedia installations. I've been working with Max/MSP/Jitter for many years, but I'd like to add a text-based language to my 'arsenal' for tasks apart from 'content production'. (When it comes to actual media synthesis, my choices are clear [Su...