March 05, 2009
Georg Wrede wrote:
> Just downloaded D 2.026 and tried rdmd. No eval?????

Sorry, inclusion of the new rdmd has not been done due to rdmd's dependency of the new phobos.

> I'd *really* appreciate a --version switch. (Probably, instead of fancy version numbers, either the repo version, and/or just plain compilation date would be nice.) Currently, since the binary is packed, there is no way to even peek at the strings in hopes of getting a clue....

What would it do?

> It also seems to accept just any switch:
> 
> $ rdmd --bullcrap="bull crap"
> Error: crap.d: No such file or directory
> 
> And from my bash dmd-wrapper log:
> 
> compiling /usr/local/digitalmars/dmd2026/linux/bin/dmd --bullcrap=bull -v -o- crap.d

Yah, rdmd passed the buck to dmd. Previously rdmd also had a bug related to whitespace in options, which in turn was a quick fix to the gorram shebang issue, which I now fixed the proper way by adding --shebang.

Anyhoo, with what I have now the erroneous flag is properly reported. Per popular demand (from one person that is :o)), I made the Linux rdmd binary available for download from http://ssli.ee.washington.edu/~aalexand/d/rdmd.


Andrei
March 05, 2009
Andrei Alexandrescu wrote:
> Georg Wrede wrote:
>> Just downloaded D 2.026 and tried rdmd. No eval?????
> 
> Sorry, inclusion of the new rdmd has not been done due to rdmd's dependency of the new phobos.
> 
>> I'd *really* appreciate a --version switch. (Probably, instead of fancy version numbers, either the repo version, and/or just plain compilation date would be nice.) Currently, since the binary is packed, there is no way to even peek at the strings in hopes of getting a clue....
> 
> What would it do?

Say I have a few DMD versions, and an rdmd with each. Then I download one from the net, and additionally I'm compiling two more. It actually happens intermittently that I end up running not the one I expect.

When all works ok, who needs to know anything. But when things don't and you're full of WTF bewilderment, then it saves time to have access to things like version.

Or suppose people start sending you bug reports. (Not impossible if rdmd gets popular.) Some admin may have moved rdmd to /usr/local/bin, somebody else got a newer version from the net... Any time I've called a hotline, the first thing they ask is what version.

>> It also seems to accept just any switch:

With --version I wouldn't even have spent time writing this, I would just have understood that I got the ancient version.

>> $ rdmd --bullcrap="bull crap"
>> Error: crap.d: No such file or directory
>>
>> And from my bash dmd-wrapper log:
>>
>> compiling /usr/local/digitalmars/dmd2026/linux/bin/dmd --bullcrap=bull -v -o- crap.d
> 
> Yah, rdmd passed the buck to dmd. Previously rdmd also had a bug related to whitespace in options, which in turn was a quick fix to the gorram shebang issue, which I now fixed the proper way by adding --shebang.
> 
> Anyhoo, with what I have now the erroneous flag is properly reported. Per popular demand (from one person that is :o)), I made the Linux rdmd binary available for download from http://ssli.ee.washington.edu/~aalexand/d/rdmd.

Got it. Thanks.

$ rdmd --eval="printf()"
/tmp/.rdmd/eval.6B6D8AE14A1B676C8EC2203340D3209A.d(10): module range cannot read file 'std/range.d'

What this means in practice is, rdmd should be "harmonised" with the DMD release it comes with.

I wonder if Walter has a makefile that generates a new DMD download? If so, then of course it could build rdmd with the appropriate imports.

March 06, 2009
Andrei Alexandrescu wrote:
> Georg Wrede wrote:
>> Should I be able to
>>
>> $ rdmd --eval='printf("Yay, rdmd!")'
>>
> 
> Yah. For my money, I can't fathom working in D without rdmd. Now with --eval and passable regexes it's even better because I can easily do tasks (from shell files) that would take longer in Perl.
> 
> Since the current source uses the not-yet-released phobos, I wanted to attach a binary so you can try it, but it's too big for the news server.
> 
> 
> Andrei

It would be nice to have a config file that lets me specify the default imports and compiler (though this would make it slower). I can send you a patch for this, but I can't seem to build rdmd without modifications; it requires a struct File that has a method popen(string). I can change File to FILE* and make a few minor changes to get it to compile, which is what I did.

Anyway, my modifications look for a config file:
in /etc/
in /usr/local/etc
in the exe directory

Currently it just looks for default imports and the compiler name. Other things to add are compiler flags, and maybe dsss support.

The solution for getting the exe directory isn't included in phobos, as far as I could tell. Perhaps you'd like to change that.


March 06, 2009
Christopher Wright wrote:
> Andrei Alexandrescu wrote:
>> Georg Wrede wrote:
>>> Should I be able to
>>>
>>> $ rdmd --eval='printf("Yay, rdmd!")'
>>>
>>
>> Yah. For my money, I can't fathom working in D without rdmd. Now with --eval and passable regexes it's even better because I can easily do tasks (from shell files) that would take longer in Perl.
>>
>> Since the current source uses the not-yet-released phobos, I wanted to attach a binary so you can try it, but it's too big for the news server.
>>
>>
>> Andrei
> 
> It would be nice to have a config file that lets me specify the default imports and compiler (though this would make it slower). I can send you a patch for this, but I can't seem to build rdmd without modifications; it requires a struct File that has a method popen(string). I can change File to FILE* and make a few minor changes to get it to compile, which is what I did.
> 
> Anyway, my modifications look for a config file:
> in /etc/
> in /usr/local/etc
> in the exe directory
> 
> Currently it just looks for default imports and the compiler name. Other things to add are compiler flags, and maybe dsss support.
> 
> The solution for getting the exe directory isn't included in phobos, as far as I could tell. Perhaps you'd like to change that.

This isn't quite ready yet, please ignore.

Also, getopt is killing --eval.
March 07, 2009
Okay, here's an improved version of rdmd with config files.

Added features:
- Config file
   - Specify a compiler
   - Specify default imports for --eval
   - Specify build flags
- Option to show source with --eval
- Changed the definition of "main" with --eval to use 'in char[][]'
rather than 'string[]' (the args probably don't matter much anyway)
- Executables are stored in the temp directory, not the current
directory. This way, they can be reused even if you change directories;
and they don't clutter up your working directory.

Attached is a sample rdmd.conf as well as the modified source (based on r958 from the phobos repository).


March 07, 2009
Christopher Wright wrote:
> Okay, here's an improved version of rdmd with config files.

Thanks, that's interesting.

> Added features:
> - Config file
>   - Specify a compiler
>   - Specify default imports for --eval
>   - Specify build flags

I'm sorry, I think a config file is overkill. Perl has many more options and does fine without any configuration besides the envvar PERL5LIB.

But indeed there must be a possibility to veer away from the hardcoded imports.

> - Option to show source with --eval

Sounds good.

> - Changed the definition of "main" with --eval to use 'in char[][]' rather than 'string[]' (the args probably don't matter much anyway)

in char[][] is the worst of the pack because it's the supertype of both immutable and mutable. You're better off with either string[] or char[][].

> - Executables are stored in the temp directory, not the current directory. This way, they can be reused even if you change directories; and they don't clutter up your working directory.

That's a good idea.

> Attached is a sample rdmd.conf as well as the modified source (based on r958 from the phobos repository).

Thanks. Let's hold off on that for a bit until we all have the same phobos.


Andrei
March 07, 2009
Christopher Wright wrote:
> Okay, here's an improved version of rdmd with config files.
> 
> Added features:
> - Config file
>   - Specify a compiler
>   - Specify default imports for --eval
>   - Specify build flags
> - Option to show source with --eval
> - Changed the definition of "main" with --eval to use 'in char[][]' rather than 'string[]' (the args probably don't matter much anyway)
> - Executables are stored in the temp directory, not the current directory. This way, they can be reused even if you change directories; and they don't clutter up your working directory.
> 
> Attached is a sample rdmd.conf as well as the modified source (based on r958 from the phobos repository).

Heh, the last line above is just another reason to include version information in rdmd!

If one is lazy, then a /very/ practical way is simply to have

   string sourceFileVersion = "20090307 190230";

where the format is "yyyyMMdd hhmmss". A Cool guy would make his editor look for this string in any .d file in the pre-save hook, and update it.

Entirely adequate, and a zero-effort amortized time complexity. :-)

######################################

Something like the below code (from Christopher's attachment) would make it possible to know unambiguously and reliably what the executing program is.

If there already isn't, there *absolutely should* exist a nice Phobos function to do just this!!!!!

In D1 too.


> version (Posix)
> {
> 	// Conforming to 4.4BSD -- this should be widely available
> 	extern(C) size_t readlink(const char* path, char* buf, size_t buflength);
> 	string exePath()
> 	{
> 		char[1024] exe;
> 		// linux, darwin, solaris support /proc/self/exe
> 		// freebsd is a laggard
> 		auto size = readlink("/proc/self/exe".ptr, &exe[0], exe.length);
> 		if (size >= 0)
> 		{
> 			return assumeUnique(exe[0..size]);
> 		}
> 		return null;
> 	}
> }

> version (Windows)
> {
> 	// Conforming to 4.4BSD -- this should be widely available
> 	extern(C) DWORD GetModuleFileName(void* ptr, char* buf, DWORD size);
> 	string exePath()
> 	{
> 		DWORD length;
> 		char[1024] buf;
> 		auto length = GetModuleFileName(null, buf.ptr, buf.length);
> 		if (length)
> 			return assumeUnique(buf[0..length]);
> 		return null;
> 	}
> }
> 



March 07, 2009
Georg Wrede wrote:
> Christopher Wright wrote:
>>     extern(C) DWORD GetModuleFileName(void* ptr, char* buf, DWORD size);

Oops, GetModuleFileName doesn't conform to 4.4BSD.

But yes, it should exist in Phobos. I looked for it in std.env and std.path and so forth, but to no avail.
March 07, 2009
Andrei Alexandrescu wrote:
> Christopher Wright wrote:
>> Okay, here's an improved version of rdmd with config files.
> 
> Thanks, that's interesting.
> 
>> Added features:
>> - Config file
>>   - Specify a compiler
>>   - Specify default imports for --eval
>>   - Specify build flags
> 
> I'm sorry, I think a config file is overkill. Perl has many more options and does fine without any configuration besides the envvar PERL5LIB.
> 
> But indeed there must be a possibility to veer away from the hardcoded imports.

It depends on whether --eval is going to be used to any reasonable degree. I don't think it is, so config files are overkill.

>> - Option to show source with --eval
> 
> Sounds good.
> 
>> - Changed the definition of "main" with --eval to use 'in char[][]' rather than 'string[]' (the args probably don't matter much anyway)
> 
> in char[][] is the worst of the pack because it's the supertype of both immutable and mutable. You're better off with either string[] or char[][].

But tango doesn't deal with string.

You could add at the top:
static if (!is (string)) alias char[] string;

>> - Executables are stored in the temp directory, not the current directory. This way, they can be reused even if you change directories; and they don't clutter up your working directory.
> 
> That's a good idea.

When I saw that rdmd put the executable with an insanely long name in my working copy, I was quite annoyed.

>> Attached is a sample rdmd.conf as well as the modified source (based on r958 from the phobos repository).
> 
> Thanks. Let's hold off on that for a bit until we all have the same phobos.

The only difference due to different phoboses is using FILE* rather than struct File.
March 08, 2009
Christopher Wright wrote:
> Andrei Alexandrescu wrote:
>> Christopher Wright wrote:
>>> Okay, here's an improved version of rdmd with config files.
>>
>> Thanks, that's interesting.
>>
>>> Added features:
>>> - Config file
>>>   - Specify a compiler
>>>   - Specify default imports for --eval
>>>   - Specify build flags
>>
>> I'm sorry, I think a config file is overkill. Perl has many more options and does fine without any configuration besides the envvar PERL5LIB.
>>
>> But indeed there must be a possibility to veer away from the hardcoded imports.
> 
> It depends on whether --eval is going to be used to any reasonable degree. I don't think it is, so config files are overkill.
> 
>>> - Option to show source with --eval
>>
>> Sounds good.
>>
>>> - Changed the definition of "main" with --eval to use 'in char[][]' rather than 'string[]' (the args probably don't matter much anyway)
>>
>> in char[][] is the worst of the pack because it's the supertype of both immutable and mutable. You're better off with either string[] or char[][].
> 
> But tango doesn't deal with string.
> 
> You could add at the top:
> static if (!is (string)) alias char[] string;
> 
>>> - Executables are stored in the temp directory, not the current directory. This way, they can be reused even if you change directories; and they don't clutter up your working directory.
>>
>> That's a good idea.
> 
> When I saw that rdmd put the executable with an insanely long name in my working copy, I was quite annoyed.
> 
>>> Attached is a sample rdmd.conf as well as the modified source (based on r958 from the phobos repository).
>>
>> Thanks. Let's hold off on that for a bit until we all have the same phobos.
> 
> The only difference due to different phoboses is using FILE* rather than struct File.

Thanks, Christopher. Just letting you (all) know, I just added support for multiple --eval occurences; stored the exe always in the temporary directory; and change the signature of main to take char[][].

Andrei
1 2 3 4
Next ›   Last »