Re: modulename

2012-09-05 Thread Jose Armando Garcia

On Sep 5, 2012, at 10:56, captaindet <2k...@gmx.net> wrote:


On 2012-09-04 15:36, Andrej Mitrovic wrote:

 9/4/12, Ellery Newcomer  wrote:

On 09/04/2012 12:41 PM, Andrej Mitrovic wrote:

__FILE__?



It doesn't necessarily have the exact package hierarchy.


We could really use __MODULE__ then. I think it's been asked before
but I didn't see any enhancement request in buzilla.


+1 would love this too

so far tried to get away with __FILE__ but this has issues, as noted  
before.



on a slightly different note, __FILE__ and __LINE__ are not quite  
doing what they are supposed to do either:


http://dlang.org/template.html
Template Value Parameters
"The __FILE__ and __LINE__ expand to the source file name and line  
number at the point of instantiation."


unfortunately, they only do this for functions (sort of¹), not for o 
ther templates.


It should work for templates too; std.log uses this extensively. Or at  
least it used to work. Can you post the code sample where it doesn't  
work?

Re: i18n

2012-02-05 Thread Jose Armando Garcia
On Sun, Feb 5, 2012 at 1:15 PM, xancorreu  wrote:
> Al 05/02/12 05:26, En/na Jose Armando Garcia ha escrit:
>>
>> On Thu, Feb 2, 2012 at 4:48 PM, xancorreu  wrote:
>>>
>>> Hi,
>>>
>>> Is there any way for localizate and internationalizate messages?
>>> I were shocked if D has something like Fantom
>>> [http://fantom.org/doc/docLang/Localization.html]. Gettext is pretty ugly
>>> ;-)
>>
>> I just glanced at Fantom because I am very much interesting in
>> localization framework design. You really think that Fantom's
>> localization design is better than gettext? What human language is
>> "$"?
>
>
> So, in conclusion, what can I do for localize outputs of programs?
>
>

I would suggest writing D binding for gettext and reading gettext
documentation...

"Most GNU packages have the ability to output messages in several
languages. This native-language support (NLS) requires the LibIntl and
the LibIconv libraries. On MS-Windows they have been adapted so that
NLS chooses the system language, unless the environment variables LANG
and LANGUAGE have been set. The language codes (ISO 639) for these
environment variables are different from the MS-Windows ones. When
using a program in a console window (command.com or cmd.exe) and
setting LANG and LANGUAGE, you must also set the correct code page
with the chcp command; for Western European languages, code page 1252
usually suffices. You can change the default code page by changing the
OEMCP value in the registry key
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage

For other languages, such as those with a Cyrillic character set, NLS
may not operate correctly, unless a TrueType font with these
characters has been chosen. If you want to disable NLS, then set the
environment variables LANGUAGE and LANG to en; then all messages will
be in English. "

Hope that helps!
-Jose


Re: i18n

2012-02-04 Thread Jose Armando Garcia
On Thu, Feb 2, 2012 at 4:48 PM, xancorreu  wrote:
> Hi,
>
> Is there any way for localizate and internationalizate messages?
> I were shocked if D has something like Fantom
> [http://fantom.org/doc/docLang/Localization.html]. Gettext is pretty ugly
> ;-)

I just glanced at Fantom because I am very much interesting in
localization framework design. You really think that Fantom's
localization design is better than gettext? What human language is
"$"?

>
>
> If not, any plannings?
>
> Thanks,
> Xan.


Re: An effort at creating a free ebook for learning D

2011-06-20 Thread Jose Armando Garcia
On Mon, Jun 20, 2011 at 7:13 PM, Kai Meyer  wrote:
> On 06/20/2011 03:46 PM, Jose Armando Garcia wrote:
>>
>> On Mon, Jun 20, 2011 at 6:30 PM, Jimmy Cao  wrote:
>>>
>>> I helped with something last summer: an attempt at creating a wikibook
>>> for
>>> D.  At that time, my D skills were very bad, so I had to concentrate on
>>> learning D first before contributing to more lessons.
>>> One thing that has always bothered me is, there aren't many good *free*
>>> ebooks for learning D.
>>> Well, I'll try to continue what I had started less than a year ago.  I'll
>>> probably make many mistakes while writing, so can you guys check on my
>>> progress once in a while?
>>>
>>> http://en.wikibooks.org/wiki/D_(The_Programming_Language)/d2/Lesson_1/Phobos
>>> What do you think?
>>> Thanks.
>>
>> Good idea. Small notes:
>>
>> *) In the tip section 'write("Hello\n") and writeln("Hello")' are not
>> the same. writeln and writefln flush. write doesn't.
>> *) Not sure if you want to also encourage portable code. "\n" should
>> be replace with newline which I think it is define in std.string.
>
> I wrote some code a while back that was intended to be portable (between
> windows and linux anyway). I used 'writef("Hello\n");' a lot, and those
> always printed correctly on windows. Does writef do something different than
> write with the '\n' character?
>
> -Kai Meyer
>

The command line console may deal with it okay but here are many
Windows programs that assume that newline is '\r\n'. That is the same
problem with '\\' and '/' for path separator. Some tools handle both
while others only handle '\\'.

-Jose


Re: An effort at creating a free ebook for learning D

2011-06-20 Thread Jose Armando Garcia
On Mon, Jun 20, 2011 at 6:30 PM, Jimmy Cao  wrote:
> I helped with something last summer: an attempt at creating a wikibook for
> D.  At that time, my D skills were very bad, so I had to concentrate on
> learning D first before contributing to more lessons.
> One thing that has always bothered me is, there aren't many good *free*
> ebooks for learning D.
> Well, I'll try to continue what I had started less than a year ago.  I'll
> probably make many mistakes while writing, so can you guys check on my
> progress once in a while?
> http://en.wikibooks.org/wiki/D_(The_Programming_Language)/d2/Lesson_1/Phobos
> What do you think?
> Thanks.

Good idea. Small notes:

*) In the tip section 'write("Hello\n") and writeln("Hello")' are not
the same. writeln and writefln flush. write doesn't.
*) Not sure if you want to also encourage portable code. "\n" should
be replace with newline which I think it is define in std.string.


Re: Strange behavior when concatenating array

2011-06-16 Thread Jose Armando Garcia
On Fri, Jun 17, 2011 at 1:05 AM, Jose Armando Garcia  wrote:
>      tests ~= test;

Btw, if you replace this with 'test[0] = test;' it works as expected.
The postblit ctor and the assignment operator get called and the dtor
is called twice.


Strange behavior when concatenating array

2011-06-16 Thread Jose Armando Garcia
It looks like the rt is not calling the postblit constructor when
concatenating arrays. For example, the following code:

import std.stdio;

struct Test
{
   this(this) { writeln("copy done"); }
   void opAssign(Test rhs) { writeln("assignment done"); }
   ~this() { writeln("destructor called"); }
}

void main()
{
   Test[] tests = new Test[1];
   {
  Test test;
  tests ~= test;
   }
   writeln("done");
}

Gives the following output:

destructor called
done

The dtr for 'Test test;' is getting call after the scope exits but the
postblit ctr for 'tests[0]' is never called. I believe the output of
this code should either be:

done

or:

copy done
destructor called
done

Thanks!
-Jose


Re: allocating gobs of memory to my program

2011-06-16 Thread Jose Armando Garcia
On Thu, Jun 16, 2011 at 10:20 PM, Charles McAnany
 wrote:
> Hm. I'm not too good on architecture - does that mean it's impossible for an 
> x32 program to have access to more memory?
> Is there, maybe, an x64 C library that I could use to abstract the memory out 
> (Just a huge array wrapper, basically)? Or, that failing, does GCC 
> automatically generate x64 code on an x64 machine? I could probably write the 
> procedure in C... but yuck.
>
> David Nadlinger Wrote:
>
>> On 6/17/11 12:32 AM, Charles McAnany wrote:
>> > Win7 x64, Intel I7 @4.4 GHz, compiling with dmd -O -release -inline.
>>
>> Regardless whether you are running on x86 or x86_64, DMD is only able to
>> create 32 bit binaries on Windows.
>>
>> David
>

I don't know why you can't allocate more than 800mb but if you want to
get around this by caching in other processes' memory then I can
recommend memcache: http://memcached.org/


Instantiating a Tuple with immutable fields.

2011-06-16 Thread Jose Armando Garcia
Hi,

I am trying to instantiate a Tuple that contains an immutable field.
Is there a way to do this with the current implementation? The
compiler gives me this error:

std/typecons.d(383): Error: can only initialize const member
_field_field_0 inside constructor
tuple_test.d(5): Error: template instance
std.typecons.Tuple!(immutable(int)).Tuple.__ctor!(int) error
instantiating
tuple_test.d(3): Error: function D main has no return statement, but
is expected to return a value of type int

here is the code:

import std.typecons;

int main()
{
  Tuple!(immutable(int)) var = Tuple!(immutable(int))(5);
  assert(var[0] == 5);
}

Thanks!


Re: Is it reasonable to learn D

2011-06-13 Thread Jose Armando Garcia
On Mon, Jun 13, 2011 at 6:33 AM, Lloyd Dupont  wrote:
> Let's learn together then! :P
> http://galador.net/codeblog/?tag=/D
>
> While my blog post are only about setting up the environment so far.. I have
> delved in the code for 2 weeks now! (Although I had some day off (work and
> programing) in Darwin) I'm right into it now, should have a new blog post
> soon! About programing this time!
>
> My verdict: it's frustrating yes. But D has a couple of advantages and 2
> that you might like:
> - D has event / delegate, just like C# (and unlike C++, or maybe C++ has
> them, (it has method pointer, right!?) but it's not taken advantage of!)
> - the above point is probably what makes the C++ GUI so... difficult.
> Whereas I found a GUI API for D just like WinForm! (DGui!)
>

Boost, GTK+ and QT have signals. E.g.
http://www.boost.org/doc/libs/1_46_1/doc/html/signals.html


Re: nested comments

2011-05-31 Thread Jose Armando Garcia
On Mon, May 30, 2011 at 11:58 PM, Jonathan M Davis  wrote:
> On 2011-05-30 19:53, Nick Sabalausky wrote:
>> "Ary Manzana"  wrote in message
>> news:is1hsa$p53$1...@digitalmars.com...
>>
>> > On 5/31/11 7:58 AM, Nick Sabalausky wrote:
>> >> "bearophile"  wrote in message
>> >> news:is1dj6$ihb$1...@digitalmars.com...
>> >>
>> >>> Jesse Phillips:
>>  The purpose is commenting out code, but note that there is also
>>  version(none) { } which is never compiled in.
>> >>>
>> >>> version(none) {} is probably the official way to comment out code.
>> >>> And if you use a versioning system to keep your code, then commenting
>> >>> out
>> >>> code is not a so wise thing to do.
>> >>
>> >> Why not? I've never heard of a VCS that went around stripping out all
>> >> comments.
>> >
>> > The question is: why comment and commit code that you can already find in
>> > the commit history? Then you end up with huge files with things like:
>> >
>> > /*
>> >
>> >  * Maybe we will use this in a future, this is not working right now
>> >  ...
>> >  ...
>> >  ...
>> >  */
>> >
>> > and the code becomes a mess.
>> >
>> > So I agree with bearophile here.
>>
>> But that applies to version(none) {}, too. Maybe I misunderstood
>> bearophile, I thought he meant "if you use a versioning system to keep
>> your code, then commenting out code [as opposed to using version(none) {}]
>> is not a so wise thing to do"
>
> I'm not sure what he meant. Personally, I don't see much value to
> version(none). I believe that the only gain that you get out of it is that the
> code must be syntactically correct. And since the code is never going to be
> used until you change the version, I don't really see much value in that.
> Comments do the job just as well.
>
> - Jonathan M Davis
>

Use static if(false) the compiler makes sure that code still compiles
at least. The problem with commented out code being saved in common
code repositories is that it can suffer from bit rust.


Strange bug in std.concurrency.spawn

2011-04-04 Thread Jose Armando Garcia
dmd can compile and run to follow the code:

unittest
{
   spawn(&fun);
}

void fun(int i) { writeln(i); }

Which if you are lucky segfaults and if you are unlucky prints
garbage! The problem is that spawn doesn't checks that the signature
of fun matches the number and type of variadic arguments. Is this a
bug in spawn(), a bug in dmd or a limitation of the language?

* If it is a bug in spawn, how can it be augmented to check this case?
* If this is a bug in dmd, I'll file a report.
* If this is a limitation of the language is this well known and it is
worked on? As it stands it doesn't seem possible to write safe
multi-threaded code.