language-design

Literal structure for time datatype

I'm working on a DSL that should support a time literal and am interested in two different things: What language(s) or DSL(s) support a time literal? How is the literal structured? I'm leaning towards using the following regular expression, extracted from the XSD for XML Schema itself, for identifying a time literal: T\d\d:\d\d:\d\d...

Are there other languages besides D with static if?

I think D's static if is an interesting language feature. That prompts my question: Are there are other examples of compiled languages in which the compiler has a strong notion of the code and there are languages facilities to access them? For example, this code provides something similar to repr from Python: char[] repr(T)(T value) { ...

Exceptions as a control mechanism

I was reading this post and laughed http://mcfunley.com/239/exceptions-are-not-a-control-mechanism In one of my apps i do not use File.Exist even tho i EXPECT files to exist a good deal of the time. I try to create a file without overwriting the older and if it fails i rename as Filename (Try Number).ext and loop until it opens. Should...

To what extent can optimisation replace Macros, Stack allocation ... ?

There is a lot of discussion about the lack of macros in some languages, and the inefficiencies that can arise. Perhaps the most common example is the guard before a log statement. To what extent can current & future optimisation be relied upon to do the right thing and obviate the need for a macro. In this example and in general? // ...

An XML language for describing file attributes of a directory tree?

I have an application in mind which will record directory listings of a file system in text form. That is, it should say something like: File name is: abc.txt Last modification date is: 2009-12-31T01:23 Read-only attribute is: True Hidden attribute is: False The listings will persist for years in a long-term archive, so the language s...

What features would you like to see in a game programming DSL?

Me and my friend are in the first stages of creating a domain-specific language designed for game programming, for his thesis paper. The language will be fairly low-level, it will have a C-like syntax, optional garbage collection, and will be geared towards systems that have little memory or processing power (ie. Nintendo DS), but shoul...

Semicolon after classes and structs

Possible Duplicate: Why must I put a semicolon at the end of class declaration in C++? Found duplicate, vote to close please. Why do classes and structs have to be concluded with semicolon in C++? Like in the following code: class myClass { }; struct muStruct { }; This syntax isn't necessary in Java or C#. Why does the...

Why programming languages do not include spaces in the method "identifiers"?

This may seem like a dumb question, but still I don't know the answer. Why do programming languages do not include spaces in the names ( for instance method names )? I understand it is to facilitate ( allow ) the parsing, and at some point it would be impossible to parse anything if spaces were allowed. Nowadays we are so use to it ...

What's wrong with type classes?

Type classes seem to be a great possibility to write generic and reusable functions in a very consistent, efficient and extensible way. But still no "mainstream-language" provides them - On the contrary: Concepts, which are a quite analogical idea, have been excluded from the next C++! What's the reasoning against typeclasses? Apparentl...

Why is 'last' called 'last' in Perl?

What is the historical reason to that last is called that in Perl rather than break as it is called in C? The design of Perl was influenced by C (in addition to awk, sed and sh - see man page below), so there must have been some reasoning behind not going with the familiar C-style naming of break/last. A bit of history from the Perl 1....

When can typeid return different type_info instances for same type?

Andrei Alexandrescu writes in Modern C++ Design: The objects returned by typeid have static storage, so you don't have to worry about lifetime issues. Andrei continues: The standard does not guarantee that each invocation of, say, typeid(int) returns a reference to the same type_info object. Even though the standard...

is there a good place to discuss compilers ?

I am looking for some place where I can discus compilers and language design ? forum or any thing of this sort ...

Using flag to identify spoken language

Hello, In the webapp I am doing, I need to identify language people are speaking. I wanted to use flag to do that. But I have some problems. For example, if you speak French, you can put the French flag. But if you speak English you can put either the US or UK flag or a mix of both. Which flag to choose for Arabic language ? Saudi Ara...

Pros and cons of Go rejecting unused dependencies

Google's new language Go tries to make dependencies management easier by explicitly requiring that all dependencies listed in a module actually be used. The compiler will reject a module that declares a dependency to a module without using anything from that module. It is illegal for a package to import itself or to import a package ...

Should References in Object-Oriented Programming Languages be Non-Nullable by Default?

Null pointers have been described as the "billion dollar mistake". Some languages have reference types which can't be assigned the null value. I wonder if in designing a new object-oriented language whether the default behavior should be for references to prevent being assigned null. A special version of the could then be used to overr...

What is the purpose of making Equals a common method?

This is not a question how to implement it but what is the purpose of this method? I mean -- OK, I understand that is needed when searching, but why it is buried as an method of "object" class? The story goes -- I have classes which objects are not comparable by default (in logical sense). Each time you want to compare/search for them y...

What are the advantages and disadvantages of the require vs. import methods of loading code?

Ruby uses require, Python uses import. They're substantially different models, and while I'm more used to the require model, I can see a few places where I think I like import more. I'm curious what things people find particularly easy — or more interestingly, harder than they should be — with each of these models. In particular, if y...

A proposal to add statemachine support to C++-like language

Lately as part of my day job I've been learning IBM Rhapsody and using it to generate code in C++ from the UML. Yesterday it struck me that it might be cool to think about adding state machine support to my C++ compiler, so I jotted a few notes here: http://ellcc.org/wiki/index.php/State%5Fmachines%5Fand%5FActive%5FClasses My motivatio...

Appropriate operators for assignment semantics in a non-pure declarative language

I'm designing a declarative language for defining signal networks. I want to use variable bindings to represent groups of nodes in the network. It occurred to me that there are two types of "assignment" I wish to do for these variables. On the one hand, a variable should represent the output of a specific group of signal operators. T...

Why do a lot of languages lack a logical XOR operator?

Off the top of my head, I cannot think of a single language I've used that had a logical exclusive or operator, but all have logical and bitwise and and or operators. Looking around, the only reason to this that I could find was that exclusive or cannot be short circuited, so a logical version would be useless, which I really can't see ...