On 19.06.2011 23:57, Jacob Carlborg wrote:
On 2011-06-19 20:41, Nick Sabalausky wrote:
"Jacob Carlborg"<d...@me.com>  wrote in message
news:itko61$1qdm$1...@digitalmars.com...
On 2011-06-18 21:35, Nick Sabalausky wrote:

I'd probably consider something more like:

orb.ver = "1.0.0";
orb.author = "Jacob Carlborg";
orb.type = Type.library;
orb.imports = ["a.d", "b.di"]; // an array of import files

That would be doable in Ruby as well. I though it would be better to not have to write "orb." in front of every method. Note the following syntax
is not possible in Ruby:

ver = "1.0.0"
author = "Jacob Carlborg"
type = Type.library
imports = ["a.d", "b.di"]

The above syntax is what I would prefer but it doesn't work in Ruby, would
create local variables and not call instance methods. Because of that I
chose the syntax I chose, the least verbose syntax I could think of.


That syntax should be doable in D.


DSSS forced an INI-similar syntax on people.


INI-syntax is trivial. Especially compared to Ruby (or D for that matter,
to
be perfectly fair).

I was thinking that the Ruby syntax was as easy and trivial as the
INI-syntax if you just use the basic, like I have in the examples. No need to use if-statements, loops or classes. That's just for packages that need
to do very special things.


But then the people who do such fancy things have to do it in Ruby instead
of D.

To take the DSSS syntax again as an example:

# legal syntax
version (Windows) {
}

# illegal syntax
version (Windows)
{
)

I assume this is because the lexer/parser is very simple. You don't have
this problem if you use a complete language for the config/spec files.


Right. And D is a complete language.


1. The amount of extra stuff is fairly minimal. *Especially* in the
majority
of cases where the user uses the standard name ("orbconf.d" or whatever
you
want to call it).

OK, I guess you can get away without the IO, but you still need the extra
processes.


That should be pretty quick.

Ok, for now I will continue with Ruby and see how it goes. One thing I do think looks really ugly in D are delegates. For the Dake config file, I'm thinking that it would allow several targets and tasks (like rake), which would looks something like this (in Ruby):

target "name" do |t|
    t.flags = "-L-lz"
end

In D this would look something like this:

target("name", (Target t) {
    t.flags = "-L-lz"
});

Or with operator overload abuse:

target("name") in (Target t) {
    t.flags = "-L-lz"
};

I would so love if this syntax (that's been suggested before) was supported:

target("name", Target t) {
    t.flags = "-L-lz"
}

Why having name as run-time parameter? I'd expect more like (given there is Target struct or class):
//somewhere at top
Target cool_lib, ...;

then:
with(cool_lib) {
    flags = "-L-lz";
}

I'd even expect special types like Executable, Library and so on.

If anyone have better ideas for how this can be done I'm listening.

One other thing, syntax below can be thought of like a compile time eval:

void main ()
{
    mixin(import("file.d"));
}

Does anyone have an idea if it would be possible to do the corresponding to instance eval that is available in some scripting languages?



--
Dmitry Olshansky

Reply via email to