Re: D users on Google+

2011-07-14 Thread Tyro[a.c.edwards]

On 7/14/2011 10:58 AM, Mike Parker wrote:

On 7/14/2011 9:10 AM, Tyro[a.c.edwards] wrote:

On 7/13/2011 5:52 PM, simendsjo wrote:

Are there any D users on Google+ I can stalk?
The only one I found was Andrei Alexandrescu, but as he works at
Facebook, I doubt he'll be posting much.



An invite would be appreciated... edwards [dot] ac [at] gmail [dot] com



Done.


Thanks Mike.


Re: D users on Google+

2011-07-13 Thread Tyro[a.c.edwards]

On 7/13/2011 5:52 PM, simendsjo wrote:

Are there any D users on Google+ I can stalk?
The only one I found was Andrei Alexandrescu, but as he works at
Facebook, I doubt he'll be posting much.



An invite would be appreciated... edwards [dot] ac [at] gmail [dot] com



Re: Inconsistencies between global imports and function local imports

2011-07-13 Thread Tyro[a.c.edwards]

On 7/13/2011 12:07 PM, Jonathan M Davis wrote:

On Wednesday 13 July 2011 11:56:10 Tyro[a.c.edwards] wrote:

Methinks function local imports (introduced in 2.054) is a great idea,
however if it is to be allowed, I believe it should provide all the
functionality of global imports: which it currently does not.

import std.stdio;
import std.string;
import std.conv;

// Note: all of these import formats work if imported here but only
// the first work if imported locally to the function.

//import std.utf;
//import std.utf: toUTF16z;
//import std.utf: wcp = toUTF16z;

void main()
{
auto s = "漢字を書くのはどうかな~?";
auto s1 = genText(s);
writeln(to!string(typeid(s1)));
}

auto genText(string t)
{
import std.utf; // This works
//import std.utf: toUTF16z; // This doesn't
//import std.utf: wcp = toUTF16z; // Neither does this

version(Unicode)
{
// Note: Everything here works with global import
// but only the first line works with function local imports

return toUTF16z(t);   // This works
//return t.toUTF16z;  // This doesn't
//return wcp(t);  // Neither does this
//return t.wcp;   // Or this
}
else
{
return t.toStringz;
}
}


import std.utf: toUTF16z;

is broken to begin with:

http://d.puremagic.com/issues/show_bug.cgi?id=314
http://d.puremagic.com/issues/show_bug.cgi?id=5161

Rather than just importing the symbol like it should, a selective import
essentially create a new symbol. So, that's probably why it doesn't work when
importing inside of a function.


IC, thanks for the response/info... Now I know!


[OT - toUTFz]

Wasn't there discussion about adding toUTFz to the std.utf? For some
reason I thought that was forthcoming in 2.054... whatever happened there?


It hasn't been merged in yet. It should be in 2.055.

https://github.com/D-Programming-Language/phobos/pull/123

- Jonathan M Davis


Got it. Thanks again.


Inconsistencies between global imports and function local imports

2011-07-12 Thread Tyro[a.c.edwards]
Methinks function local imports (introduced in 2.054) is a great idea, 
however if it is to be allowed, I believe it should provide all the 
functionality of global imports: which it currently does not.


import std.stdio;
import std.string;
import std.conv;

// Note: all of these import formats work if imported here but only
// the first work if imported locally to the function.

//import std.utf;
//import std.utf: toUTF16z;
//import std.utf: wcp = toUTF16z;

void main()
{
auto s = "漢字を書くのはどうかな~?";
auto s1 = genText(s);
writeln(to!string(typeid(s1)));
}

auto genText(string t)
{
import std.utf; // This works
//import std.utf: toUTF16z; // This doesn't
//import std.utf: wcp = toUTF16z; // Neither does this

version(Unicode)
{
// Note: Everything here works with global import
// but only the first line works with function local imports

return toUTF16z(t);   // This works
//return t.toUTF16z;  // This doesn't
//return wcp(t);  // Neither does this
//return t.wcp;   // Or this
}
else
{
return t.toStringz;
}
}


[OT - toUTFz]

Wasn't there discussion about adding toUTFz to the std.utf? For some 
reason I thought that was forthcoming in 2.054... whatever happened there?


Re: D brand identity repository

2011-06-30 Thread Tyro[a.c.edwards]

On 7/1/2011 7:39 AM, Chris Molozian wrote:

It's a great logo Mafi, is it possible to try it without the italics and
see what that looks like?

IMHO it's between:

https://github.com/eegg/d-brand/raw/master/d-logo-7.png
AND
https://github.com/eegg/d-brand/raw/master/dlogo-mafi.png


Though I like d-logo-7, I think the logical choices rest between these two:

http://envisionic.com/images/d-logo-draft.png
AND
http://imgur.com/J1pbr


Thanks for the hard work guys, beauty surrounding the D language is just
as important (arguably more important) as the beauty of the language
itself.

Chris



Re: D brand identity repository

2011-06-30 Thread Tyro[a.c.edwards]

On 7/1/2011 5:37 AM, James Fisher wrote:

On Thu, Jun 30, 2011 at 9:27 PM, Tyro[a.c.edwards] mailto:nos...@home.com>> wrote:

On 7/1/2011 12:38 AM, James Fisher wrote:

https://github.com/eegg/d-__brand/raw/master/d-logo-1.png
<https://github.com/eegg/d-brand/raw/master/d-logo-1.png>


That explains it! The Devil's religion. Nope... Definitely not
interested.


IC ... ಠ_ಠ


Don't get me wrong... It looks good... but it's the wrong clothing for D 
the Language.


Re: D brand identity repository

2011-06-30 Thread Tyro[a.c.edwards]

On 7/1/2011 5:58 AM, Mafi wrote:

Am 30.06.2011 22:39, schrieb James Fisher:

On Thu, Jun 30, 2011 at 9:29 PM, Andrej Mitrovic
mailto:andrej.mitrov...@gmail.com>> wrote:

On 6/30/11, James Fisher mailto:jameshfis...@gmail.com>> wrote:
> Here's Mafi's suggestion in PNG:
> https://github.com/eegg/d-brand/raw/master/dlogo-mafi.png

Odd, in my browser the D letter looked really thin when I viewed the
SVG. Maybe it was a rendering bug.


GP -- Mafi left it in Verdana, which I don't have here, so that PNG is
actually DejaVu Sans. Heh. Mafi, if you could convert to a path?


Sometimes svg behaves odd...
I've attached the path-version.
I've also uploaded a rendering at http://imgur.com/J1pbr because the
above looks a bit different than mine.


Don't Spoil a good thing... The original size was perfect. Any bigger 
and, I'm starting to have doubts.



Mafi

PS: I license these images with CC-0.


Re: D brand identity repository

2011-06-30 Thread Tyro[a.c.edwards]

On 7/1/2011 4:02 AM, Steven Schveighoffer wrote:

On Thu, 30 Jun 2011 14:12:58 -0400, James Fisher
 wrote:


Sure thing: https://github.com/eegg/d-brand/raw/master/d-logo-5.png


I have to say, I like this one the best. Even better than the original.


And a more radical departure:
https://github.com/eegg/d-brand/raw/master/d-logo-7.png . Again just
proof-of-concept. Solves the visual stretch required for the D-as-planet.
However, perhaps the capitalization is too firmly set in in the
community.


Departure notwithstanding, I actually like this one... Were not for the 
recent post by Mafi, this would be my only choice of the proposals thus far.



Yeah, I'm not sure lowercase works well. Also, that looks like a
sideways snowman :)

-Steve




Re: D brand identity repository

2011-06-30 Thread Tyro[a.c.edwards]

On 7/1/2011 4:35 AM, Mafi wrote:

This is my try.
What do you guys think about it?


Now there's an Idea. Simple yet elegant... no boobs and retains the 
historical reference to Mars and her two moons. I like it. I'll even 
take the italics.


++ Vote

Oh wait, I only have one vote.


Re: D brand identity repository

2011-06-30 Thread Tyro[a.c.edwards]

On 7/1/2011 12:38 AM, James Fisher wrote:

https://github.com/eegg/d-brand/raw/master/d-logo-1.png


That explains it! The Devil's religion. Nope... Definitely not interested.


More playing around.  Criticisms:

- it's a bit busy
- as a rule, gradients don't add any worth
- mixes planet/devil metaphors to a degree that the planet metaphor is lost


Re: D brand identity repository

2011-06-30 Thread Tyro[a.c.edwards]

On 6/30/2011 9:54 PM, James Fisher wrote:

On Thu, Jun 30, 2011 at 11:55 AM, Walter Bright
mailto:newshou...@digitalmars.com>> wrote:

We've pretty much settled on the logo used on
d-programming-language.org . It
would be nice to get it rendered in various sizes.


Fair enough.  It seems there's no source for it around (just the PNG),
so I've been vectorizing.

In the process, I thought I may as well throw my suggestion into the
mix: https://github.com/eegg/d-brand/raw/master/d-logo.png


Woo... Wait a second! What religion is this again? Don't like it,
I'll keep what we got right now.


Basically, I like the core idea of the logo at d-p-l.org
.  One thing that doesn't work so well is the
shiny iconized background.  A logo should be *simple*, and I think this
just detracts from the nice central idea.  To this end I have removed
it: I think the logo itself should just be the Mars-and-satellites detail.

The other thing that doesn't work is, and forgive my crudeness, it looks
like a lactating breast.  Once I realized this I have unfortunately been
unable to shake the image from my mind.  To this end I have introduced a
white highlight to the satellites.  (I'm still not sure this fully
removes the image.)

One side-effect of this you might like is that the crescent
simultaneously acts as "devil's horns", reminiscent of this charming
little guy  who seems to have been
forgotten.

Obviously, this is a prototype.  The alignment and composition could be
worked on.


htmlget.d example and unicode parsing

2011-04-30 Thread Tyro[a.c.edwards]

Hello all,

I am trying to learn how to parse, modify, and redisplay a Japanese 
webpage passed to me in a form and am wondering if anyone has an example 
of how to do this.


I looked at htmlget and found that it has a couple problems: namely, it 
is not conform to current D2 practices. I am not sure that my hack can 
be considered a fix but have attached it nonetheless. It now works 
correctly on ascii based urls but not utf-8.


My lack of knowledge on how to properly parsing unicode documents has 
left me stumped. I am therefore requesting some assistance in updating 
the code such that it works with any url. I have taken a look at std.utf 
and there are a few things there that could possibly assist me however 
without examples I'm somewhat at a loss.


I'm assuming that the problem exists here:

for (iw = 0; iw != line.length; iw++)
{
if (!icmp("", line[iw .. line.length]))
break print_lines;
}

From what I understanding, one cannot index a utf sequence the same as 
you index ASCII. What is the proper what to rewrite this such that it 
parses the utf characters correctly? And example would do wonders.


Thanks

/*
HTMLget written by Christopher E. Miller
This code is public domain.
You may use it for any purpose.
This code has no warranties and is provided 'as-is'.
 */

// debug = HTMLGET;

import std.string, std.conv, std.stream;
import std.socket, std.socketstream;
import std.algorithm, std.stdio;
import std.utf;

int main(string[] args)
{
if (args.length < 2)
{
writef("Usage:\n   htmlget \n");
return 0;
}

string url = args[1];
int i;

i = std.algorithm.countUntil(url, "://");

if (i != -1)
{
if (icmp(url[0 .. i], "http"))
throw new Exception("http:// expected");
}

std.algorithm.findSkip(url, "://");
i = std.algorithm.countUntil(url, '#');

if (i != -1)// Remove anchor ref.
url = url[0 .. i];

i = std.algorithm.countUntil(url, '/');
string domain;

if (i == -1)
{
domain = url;
url= "/";
}
else
{
domain = url[0 .. i];
url= url[i .. url.length];
}

ushort port;
i = std.algorithm.countUntil(domain, ':');

if (i == -1)
{
port = 80; // Default HTTP port.
}
else
{
port   = std.conv.to!ushort(domain[i + 1 .. domain.length]);
domain = domain[0 .. i];
}

debug (HTMLGET)
writef("Connecting to " ~ domain ~ " on port " ~ 
std.string.toString(port) ~ "...\n");

/*auto*/ Socket sock = new TcpSocket(new InternetAddress(domain, port));
Stream ss= new SocketStream(sock);

debug (HTMLGET)
writef("Connected!\nRequesting URL \"" ~ url ~ "\"...\n");

if (port != 80)
domain = domain ~ ":" ~ std.conv.to!string(port);

ss.writeString("GET " ~ url ~ " HTTP/1.1\r\n"
   "Host: " ~ domain ~ "\r\n"
   "\r\n");

// Skip HTTP header.
char[] line;

for (;;)
{
line = ss.readLine();

if (!line.length)
break;

const string CONTENT_TYPE_NAME = "Content-Type: ";

if (line.length > CONTENT_TYPE_NAME.length &&
!icmp(CONTENT_TYPE_NAME, line[0 .. CONTENT_TYPE_NAME.length]))
{
char[] type;
type = line[CONTENT_TYPE_NAME.length .. line.length];

if (type.length <= 5 || icmp("text/", type[0 .. 5]))
throw new Exception("URL is not text");
}
}

print_lines:

while (!ss.eof())
{
line = ss.readLine();
writef("%s\n", line);

// if(std.string.ifind(line, "") != -1)
//  break;
//size_t iw;

foreach (iw, val; line)
{
//iw = toUTFindex(line, iw);
writefln("%d: %s",iw,val);
std.algorithm.findSkip(url, "");
if (!icmp("", line[iw .. line.length]))
break print_lines;
}
}

return 0;
}

Re: Hidden links for Language Reference on d-programming-language.org

2011-02-20 Thread Tyro[a.c.edwards]

On 2/21/2011 7:47 AM, Tyro[a.c.edwards] wrote:

The links for Documentation: Language Reference gets hidden when you
click on any of the following four items:

o Lexical
o Templates
o Inline Assembler
o Documentation Comments

- Andrew


By the way you cannot get to the list by clicking on Language Reference 
(http://d-programming-language.org/language-reference.html).


Hidden links for Language Reference on d-programming-language.org

2011-02-20 Thread Tyro[a.c.edwards]
The links for Documentation: Language Reference gets hidden when you 
click on any of the following four items:


o   Lexical
o   Templates
o   Inline Assembler
o   Documentation Comments

- Andrew


Re: Principled method of lookup-or-insert in associative arrays?

2010-11-20 Thread Tyro[a.c.edwards]

On 11/21/2010 10:39 AM, Tomek Sowiński wrote:

Dnia 21-11-2010 o 02:02:35 Tyro[a.c.edwards]  napisał(a):


The harm is confusion. Now = on arrays always means aliasing, but with
your proposal, it may *sometimes* mean dupping. Imagine real-life code
with type aliasing and type inference in play, and trying to determine
whether some line makes a dupping string<->char[] conversion or not.


alias char[] firstClassString;
alias firstClassString stringGold;
alias stringGold lightAtEndOfTunnel;
alias lightAtEndOfTunnel daBomb;
alias daBomb iAmThe;
iAmThe man;
if I want to know the actual type of shiznit:
writeln(typeid(man)); // outputs char[]


What would be the harm if everyone just put .(i)dup where it belongs?


Actually, I don't see any harm in using .(i)dup. However, my limited
experience does not allow me to think on the same level as you so I'm
just trying to understand your point a little better. That being said,
I still don't understand the gravity of the implied problem.


The status quo is imposing a tiny upfront tax on the writer of typing
.(i)dup.
The proposal is imposing a minor tax on the reader of knowing another
rule and, in case of convoluted code like above, minor tax of
determining if this rule applies. Plus, some tax on the implementor to
put this rule into the compiler.


OK! Makes sense.


The point is the aggregated tax imposed by the proposal is much greater
because although minor it grows linearly with the number of readers
(code is read much more often then written). And even with finite set of
readers, the tax grows till infinity because with time people forget
what they read, therefore the tax is collected anew.

And think of the gains -- dropping .(i)dup doesn't really buy you much
anyway.



Fair enough. Like I said, I'm not proposing that this happens. Just 
trying to understand why it shouldn't. Thanks for entertaining my questions.


Re: Principled method of lookup-or-insert in associative arrays?

2010-11-20 Thread Tyro[a.c.edwards]

On 11/21/2010 9:23 AM, Tomek Sowiński wrote:

Tyro[a.c.edwards]  napisał(a):


What would be the harm if upon seeing your code the compiler did this:
char[] chars = "abc".dup;
char[] backdoor = chars;
string s = chars.idup;
assert (s == "abc");
backdoor.front = 'k'; // [1]
assert (s == "abc");
Slightly magical but works according to expectation. I don't see the
problem.
[1] Assuming your are using std.array, this would fail because
backdoor.front is not an lvalue.


The harm is confusion. Now = on arrays always means aliasing, but with
your proposal, it may *sometimes* mean dupping. Imagine real-life code
with type aliasing and type inference in play, and trying to determine
whether some line makes a dupping string<->char[] conversion or not.


alias char[] firstClassString;
alias firstClassString stringGold;
alias stringGold lightAtEndOfTunnel;
alias lightAtEndOfTunnel daBomb;
alias daBomb iAmThe;

iAmThe man;

if I want to know the actual type of shiznit:

writeln(typeid(man)); // outputs char[]


What would be the harm if everyone just put .(i)dup where it belongs?



Actually, I don't see any harm in using .(i)dup. However, my limited 
experience does not allow me to think on the same level as you so I'm 
just trying to understand your point a little better. That being said, I 
still don't understand the gravity of the implied problem.


Re: Principled method of lookup-or-insert in associative arrays?

2010-11-20 Thread Tyro[a.c.edwards]

On 11/20/2010 9:39 PM, Michel Fortin wrote:

On 2010-11-20 03:07:57 -0500, Andrei Alexandrescu
 said:


TDPL has an example that can be reduced as follows:

void main() {
uint[string] map;
foreach (line; stdin.byLine()) {
++map[line];
}
}

byLine reuses its buffer so it exposes it as char[]. Therefore,
attempting to use map[line] will fail. The program compiled and did
the wrong thing because of a bug.

The challenge is devising a means to make the program compile and work
as expected. Looking up an uint[string] with a char[] should work, and
if the char[] is to be inserted, a copy should be made (via .idup or
to!string). The rule needs to be well defined and reasonably general.

The effect is something like this:

void main() {
uint[string] map;
foreach (line; stdin.byLine()) {
auto p = line in map;
if (p) ++*p;
else map[line.idup] = 1;
}
}

Ideally the programmer would write the simple code (first snippet) and
achieve the semantics of the more complex code (second snippet). Any
ideas?


But didn't you agree with me yesterday in another thread that it's best
to make the caller responsible for the idup in cases where you need a
string to be immutable? Now you want the reverse for AAs?

Consider this example:

uint[string][100] maps;
foreach (line; stdin.byLine()) {
foreach (map; maps) {
++map[line];
}
}

With your proposal, you'd be silently iduping 100 times each line to
produce 100 times the same immutable string.


Maybe I'm not knowledgeable enough to understand but, if I need to do 
this under the current constraints I would have to write 
++map[line.idup]. In effect I end up duping 100 times anyway. Or is 
there another solution that I'm just not seeing?



It's true that it's difficult to make the caller responsible for iduping
the string since whether you need a true immutable string or not depends
on a test, but I'm still wary about functions that idup things on your
behalf.






Re: Principled method of lookup-or-insert in associative arrays?

2010-11-20 Thread Tyro[a.c.edwards]

On 11/20/2010 11:22 PM, Tomek Sowiński wrote:

Dnia 20-11-2010 o 13:33:29 spir  napisał(a):


I find this proposal really necessary. But aren't there two issues here?
* Comparison (for lookup) by value equality should not care about
qualifiers (ie compare raw content, here plain array memory areas).
* Assignment should perform "qualification conversion" automatically, eg
char[] chars = "abc";
string s = chars;
This involves no implicit magic here, as target qualification is
explicit. So, why not?


It's busting the whole const system to smithereens.

char[] chars = "abc";
char[] backdoor = chars;
string s = chars;
assert (s == "abc");
backdoor.front = 'k';
assert (s == "abc"); // fails. not so immutable, huh?


What would be the harm if upon seeing your code the compiler did this:

char[] chars = "abc".dup;
char[] backdoor = chars;
string s = chars.idup;
assert (s == "abc");
backdoor.front = 'k';   // [1]
assert (s == "abc");

Slightly magical but works according to expectation. I don't see the 
problem.


[1] Assuming your are using std.array, this would fail because 
backdoor.front is not an lvalue.





There is a repetitive programming pattern in D:
* play around with *string's in general
* as soon as text processing is needed, convert to *char[]
* when finished, convert back to *string


Meh, immutable strings make life easier.





Re: Error 42: Symbol Undefined __d_throwc

2010-11-20 Thread Tyro[a.c.edwards]

On 11/21/2010 1:13 AM, Jimmy Cao wrote:

I can't reproduce it on Windows 7 with dmd 2.050.

On Sat, Nov 20, 2010 at 12:45 AM, Tyro[a.c.edwards] mailto:nos...@home.com>> wrote:

The following:

import std.regex;

void main()
{
string s = "$,";
replace(s, regex("$",","), ""); // Is this possible?  If so,
what is the propper way to do it?
assert(s == "", s);
}

Compiled with dmd.2.039, 042, 048, and 049 but yields a runtime error:
D:\code>bug
object.Exception: unrecognized attribute



That bit of info actually fixed linker error portion of my problem. 
Seems my copy of dmd 2.050 got corrupted. Trying to run the program 
still results in the runtime error above. Any ideas?


Thanks,
Andrew


Error 42: Symbol Undefined __d_throwc

2010-11-19 Thread Tyro[a.c.edwards]

The following:

import std.regex;

void main()
{
string s = "$,";
	replace(s, regex("$",","), ""); // Is this possible?  If so, what is 
the propper way to do it?

assert(s == "", s);
}

Compiled with dmd.2.039, 042, 048, and 049 but yields a runtime error:
D:\code>bug
object.Exception: unrecognized attribute

Compiled with dmd.2.050, it yields the linker error:
D:\code>dmd bug
OPTLINK (R) for Win32  Release 8.00.8
Copyright (C) Digital Mars 1989-2010  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
bug.obj(bug)
 Error 42: Symbol Undefined __d_throwc
--- errorlevel 1

I grepped my hard drive for _d_throwc and found the following:
D:\code>grep -r -i _d_throwc d:\*.*
\dmd2\linux\lib\libphobos2.a:_d_throwc
\dmd2\linux\lib\libphobos2.a:.text._d_throwc
\dmd2\linux\lib\libphobos2.a:.rel.text._d_throwc
\dmd2\osx\lib\libphobos2.a:__d_throwc
\dmd2\src\dmd\dmd.exe:_d_throwc
\dmd2\src\dmd\rtlsym.obj:_d_throwc
\dmd2\src\dmd\backend\rtlsym.h:SYMBOL_MARS(THROWC,  FLfunc,(mES 
| mBP),"_d_throwc", SFLexit, t) \

\dmd2\src\druntime\deh.obj:__d_throwc..
\dmd2\src\druntime\lib\druntime.lib:__d_throwc..
\dmd2\src\druntime\lib\druntime.lib:__d_throwc.
\dmd2\src\druntime\src\rt\deh.c:void _d_throwc(Object *h)
\dmd2\src\druntime\src\rt\deh2.d:extern (C) void _d_throwc(Object *h)
\dmd2\src\phobos\phobos.lib:__d_throwc..
\dmd2\windows\bin\dmd.exe:_d_throwc

Redundant entries were removed for brevity.

Function _d_throwc is defined on line 152 of 
dmd2\src\druntime\src\rt\deh2.d and line 232 of 
dmd2\src\druntime\src\rt\deh.d. I do not know how to correct the problem 
however it does seem odd that Linux's libphobos2.a uses the same name as 
was originally defined "_d_throwc" while OSX's libphobos2.a, 
druntime.lib and phobos.lib are different. Note that this function did 
not exist prior to dmd.2.050. Don't know if it matters but I'm using 
Win7. Any assistance is appreciated.


Andrew


Re: problems playing audio with mciSendString

2010-11-02 Thread Tyro[a.c.edwards]
Thanks,

The�problem�was�that�mciSendString�was�immediately�returning�control
to�the�caller�after�being�called.�This�simple�change�fixed�the
problem:

mciSendString("play�myFile�wait");



problems playing audio with mciSendString

2010-11-02 Thread Tyro[a.c.edwards]
== Repost the article of Tyro[a.c.edwards] (nos...@home.com)
== Posted at 2010/11/02 04:26 to digitalmars.D.learn

Hello�all,

I�would�really�appreciate�some�assistance�on�this.�The�intent�is�to
create�a�vocabulary/flashcard�program�with�proper�pronunciations.
Pronunciations�are�saved�as�individual�mp3�files�which�I�want�to
play�whenever�a�new�term�is�displayed.�My�current�attempt�is�simply
to�get�the�the�file�(any�mp3�file�really)�to�play.�All�indication
form�the�two�references�I'm�using�(http://msdn.microsoft.com/en-
us/library/dd757161(v=VS.85).aspx�and
http://www.apitalk.com/windows-Programming/Play-Mp3,-Wav,-Wmv,-Mpg,-
Avi-Etc-Files-In-Win32-Api-Program.html)�say�that�this�little�script
is�supposed�to�work.�The�error�codes�as�reported�by�mciSendString
even�suggest�that�it�is�working,�however�I'm�not�hearing�any�sound
at�all.

suggestions�anyone?

import�std.stdio�:�writeln;
import�std.string�:�cstring�=�toStringz;
import�std.c.windows.windows;

pragma(lib,�"winmm.lib"�);

extern(Windows)�{
�uint�mciSendStringA(
��LPCTSTR�lpszCommand,
��LPTSTR�lpszReturnString,
��uint�cchReturn,
��HANDLE�hwndCallback);
}

uint�mciSendString(string�s)
{
�return�mciSendStringA(�cstring(s),�cast(LPTSTR)null,�0,
cast(HANDLE)0�);
}

void�main()
{
�auto�exist�=�mciSendString("open�CC_10_mins.mp3�type
mpegvideo�alias�myFile");

�auto�succeeded�=�mciSendString("play�myFile");

�auto�closed�=�mciSendString("close�myFile");

�writeln(�exist,�"�-�",�succeeded,�"�-�",�closed�);
}


PROGRAM�OUTPUT
==

when�file�exists:
D:\code>play
0�-�0�-�0

when�file�does�not�exist:
D:\code>play
275�-�263�-�263


Re: Backquotes look like regular quotes in TDPL?

2010-06-28 Thread Tyro[a.c.edwards]
== Quote from Jacob Carlborg (d...@me.com)'s article
> Is it just me or are the backquotes looking like regular quotes in
TDPL?
> They're introduced on page 36, section 2.2.5.1.

It's not you, they do in fact look like regular quotes. That however, is
a byproduct of the font chosen. Look closely at the character used at
the top of table 2.3 of the same page and compare that to the one in
§2.2.5.1 and I'm sure you will see a distinct difference.


Re: [TDPL] arrays of D future

2010-06-27 Thread Tyro[a.c.edwards]
== Quote from Lutger (lutger.blijdest...@gmail.com)'s article
>  wrote:
> > Andrei,
> >
> > I must say that the reading is absolutely enjoyable. I do have one
> > question regarding the StackImpl example on page 234. Are you
forecasting
> > future functionality that arrays will support with your use of
.empty, .back,
> > and .popBack or am I too na�ve to understand that I need to
implement this
> > functionality in order for your example to compile?
> These functions are implemented in std.array, you only need to
import that
> module.

Thanks.


[TDPL] arrays of D future

2010-06-27 Thread Tyro[a.c.edwards]
Andrei,

I must say that the reading is absolutely enjoyable. I do have one
question regarding the StackImpl example on page 234. Are you forecasting 
future functionality that arrays will support with your
use of .empty, .back, and .popBack or am I too na�ve to understand
that I need to implement this functionality in order for your example
to compile?


readf anyone?

2010-06-22 Thread Tyro[a.c.edwards]
So I'm digging in and enjoying the read (and let me tell you it's a
pretty interesting read), then I flip to page 22 (I read slow) and
stumbled onto this code:

for (double x; readf(" % ", &x) == 1; ) {
   [snip]
}

Wait that don't look right. I don't remember readf() being
implemented. So I decided to check things out. I jimmied up this
little rig:

void main() {
double q;
readf("%s", &q);
writeln(q);
}

and launched it:

D:\code>dmd input
input.d(5): Error: undefined identifier readf, did you mean function
readln?

well that didn't work. Maybe I'm missing something. Let me take a
look an the phobos doc: no, no mention there. Oh, I got it, I don't
have the latest compiler (how stupid of me). Downloading...
Installing... recompiling. Damn, that wasn't it. Ok, let me take a
look at std.stdio.d. There it is, it's a member function of class
File. Ok, I should be able to access it through stdin. Let me try
that instead:

void main() {
double q;
stdin.readf("%s", &q);
writeln(q);
}

Here goes nothing:

D:\code>dmd read
d:\dmd2\windows\bin\..\..\src\phobos\std\format.d(2948): Error: no
property 'len
gth' for type 'InputByChar'

Damn, that didn't work either. Now that's crazy, why would we use
this function in the book and not take the extra effort to ensure
that it's actually implemented before going to print? Was this an
oversight? If so, can we please get the fix.


Re: This just in: authorless TDPL becomes collector's edition

2010-06-22 Thread Tyro[a.c.edwards]
good for you, sucks for me though, I didn't get a collector's edition
and I ordered my copy back in over six months ago.


Re: All this talk about finalising D2 makes me worried

2009-07-16 Thread Tyro [a.c.edwards]

Bill Baxter wrote:

On Wed, Jul 15, 2009 at 6:21 PM, Steven
Schveighoffer wrote:

On Wed, 15 Jul 2009 13:22:30 -0400, Stewart Gordon 
wrote:


Well D1.0 was pretty much an arbitrary line in the sand.
D2.0release (or whatever they decide to call it) might as well be too.


And if memory serves me correctly, that was the direct result of 
innumerable request by the community for that line to be drawn. I 
seriously doubt we want to do the same thing again.



--bb


Re: What's the current state of D?

2009-05-08 Thread Tyro[a.c.edwards]

On 5/9/2009 11:24 AM, grauzone wrote:

beyond and I'm quite sure that I'm not the only one. For all the
Naysayers out there... Keep saying nay and go the hell away. D2 is
just where it is supposed to be. Let’s not end up in the same mess we
did by trying to make impatient people happy and releasing D1.


What about the people who want to use D for something actually useful?


Well, for those cases, there is D1. Which, if I may add, is extremely 
stable. Take a network administrator running his server or firewall on 
say DragonFly or any of the many flavors of BSD or Linux; he does not 
upgrade his server with nightly builds, he sticks instead with a 
"stable," well tested branch of the OS and experiments with "current." 
When current becomes stable, the OS developer does not stop developing 
his OS, he continues on with his vision while the "users" further 
stress-tests the newly stabilized branch and take steps to find and 
correct any holes in the system. And our system administrator, well, he 
doesn't switch until he is comfortable that the newly stabilized branch 
meets all his criteria for upgrade. If they are not met... he waits 
until the OS branches again.


We cannot expect the compiler developer to stop developing compilers 
until after the tools developers decide to build tools. He has done his 
job, which is to develop a stable, documented compiler. Use it to 
develop your tools which will in turn allow the compiler/language to 
gain popularity. Report any bug reports on anything that seems out of 
the ordinary so that it can either be clarified in documentation or 
corrected with code.


Walter is a damn good Engineer but I don't think his interests lie in 
writing tools (IDE and the like). So those people that do write those 
tools may want to take the "stable" compiler and start developing. So 
what if this feature "that is in D2" is not in D1? Use what you have in 
D1 and develop your tools and simply stay abreast with the development 
of D2 so that when it is time to switch, you are not in the dark.


Andrew


Re: What's the current state of D?

2009-05-08 Thread Tyro[a.c.edwards]

On 5/9/2009 3:38 AM, Steve Teale wrote:

Walter Bright Wrote:


Steve Teale wrote:

This is the sort of answer that will kill D. The guy comes back after
2 years, asks a straight question, and get's told "business as usual,
we're still arguing among ourselves about what it should be".

Maybe Tiobe is right! Lots of others may not even bother to ask. They
just visit the newsgroup, read a page of it, and conclude "same old,
same old", and go away.

D should be D, not maybe 1.043, or let's wait a while and see what
happens with D2. Potential real users hate uncertainty. If they are
going to commit, then D must do so too.

What bothers me about this sentiment is that every other mainstream
language undergoes revision, sometimes major ones, but that never seems
to be an excuse for people to not use it.

For example, C++ is quite in flux with C++0x.

The only languages that are not undergoing revision are dead ones.


Yes Walter, but C++ went through a tedious standardization process - itself a 
long argument. So there was some basis for people to think that it had 'got 
there'.

But to come back after 2 years and find the same stuff still going on is 
depressing - been there done that. OK, it didn't put me off, I'm still in 
there, but it bothers me. I'd be dishonest if I said otherwise.

I am not criticizing you. I think you are doing a great job under the pressure 
of a slew of suggestions. But maybe a line in the sand at some point?

OK so for those who crave stability there is D1.x, but when all the focus 
appears to be on D2, what level of confidence is afforded to D1 users. Can a 
project Manager cross his heart and say that D1 will still be alive and well in 
five years time?



This is quite interesting! Before there was D1, I can remember the same 
requests being submitted over and over again. Tool developers complained 
that they could not use D for anything serious because of its constant 
state of flux. They continuously requested that a line be drawn. 
Shortly after that line was drawn in January 2007, a good majority of 
the community complained that it wasn't exactly what they asked for and 
a majority of the most active members of the community disappeared into 
thin air.


The sad thing is, even after D1 became stable following a number of bug 
fixes, very few people used it for much of anything. Those "advocates of 
stability" all disappeared; abandoning their tools/projects in the process.


The same thing is beginning again and it seems to me that instead of 
something that is actually useful, people a waiting for MicroMoney or 
some other name brand begins to invest in their own D compiler. As far 
as I see it, there will come a time when D language will soar above all 
the rest (not only in capability, which it already does, but also 
commercial usage), I will continue to support it until then and well 
beyond and I'm quite sure that I'm not the only one. For all the 
Naysayers out there... Keep saying nay and go the hell away. D2 is just 
where it is supposed to be. Let’s not end up in the same mess we did by 
trying to make impatient people happy and releasing D1.


Andrew


Re: Error: xxx is not an lvalue

2009-05-03 Thread Tyro[a.c.edwards]

On 5/3/2009 8:17 PM, Unknown W. Brackets wrote:

Well, if you really want a "protected" associative array, or array for
that matter, you probably should define a wrapper class that inlines the
access you're willing to allow.

 From a basic perspective, _testMap is a structure of data. Although it
is private, there's no reason it can't be modified through an accessor.

Without a setter, the only thing that should fail is test.testMap =
something. Requiring a setter for any minor change makes no sense.


I was following until now... If I can modify said private member at a
whim, why on earth would I prevent this case? Is this because I would
be assigning it a completely new value vice simply modifying its
content? If that is the case, am I correct in saying that this
characteristic is applicable only to arrays?


Compare it to this: if you have a class that has a member object (e.g. a
User with a Socket member variable), should it be necessary to have a
setter to change the Socket? Can't the Socket handle its own
private/public-ness?

Arrays and associative arrays are the same, except that the members you
use are public.

-[Unknown]


Got you... I think I understand. That being the case though, wouldn't
it be just as useful to build the same "accessor" capability into
opAssign such that you can:

class Foo
{
private sometype _data;
public ref typeof(_data) opAssign() { return _data; }
}

Foo b = new foo;
b[0] = 1;

Why is it necessary to have a separate/different "accessor" function?



Tyro[a.c.edwards] wrote:

On 5/3/2009 6:25 PM, Unknown W. Brackets wrote:

This code works fine (D 2.x only):

class Test
{
private int[int] _testMap;
public ref int[int] testMap() {return _testMap;}
}

void main()
{
Test test = new Test();
test.testMap[0] = 1;
}

Note the "ref". Otherwise, a value is returned which is not modifiable.
This will also fix test.array.length. Nothing wrong here, no creepy bad
temporary property problems.


Is this an intended or even desirable "feature" of the language or
just something that happens to work in D 2.x? I ask because to the
untrained eye, it is unclear exactly what is happening. There is
nothing to inform me that _testMap can be modified from outside the
class. Even with "ref" there it doesn't make it any clearer.

Matter of fact, I just had a problem in Phobos 2 where a function was
defined like that and I had to comment out the "ref" for it to work.
Kept telling me that some array was not an lvalue. The minute I
commented out the "ref", everything worked like a charm.

Also it makes more sense to me to have separate functions as getters
and setters. Maybe that's only because I lacking proper training in
the art of computer programming though.


I suppose you could also try returning a pointer to an associative array
(e.g. with &) in D 1.x.

-[Unknown]

flourish wrote:

Hi,

why does the following code not compile -- or how to declare a (usable)
property of an associative array field?

//
class Test
{
private int[int] _testMap;
public int[int] testMap() {return _testMap;}
}


void main()
{
Test test = new Test();
test.testMap[0] = 1;
}
/

*** Error: test.testMap() is not an lvalue


Regards,
flourish









Re: Error: xxx is not an lvalue

2009-05-03 Thread Tyro[a.c.edwards]

On 5/3/2009 6:25 PM, Unknown W. Brackets wrote:

This code works fine (D 2.x only):

class Test
{
private int[int] _testMap;
public ref int[int] testMap() {return _testMap;}
}

void main()
{
Test test = new Test();
test.testMap[0] = 1;
}

Note the "ref". Otherwise, a value is returned which is not modifiable.
This will also fix test.array.length. Nothing wrong here, no creepy bad
temporary property problems.


Is this an intended or even desirable "feature" of the language or just 
something that happens to work in D 2.x? I ask because to the untrained 
eye, it is unclear exactly what is happening. There is nothing to inform 
me that _testMap can be modified from outside the class. Even with "ref" 
there it doesn't make it any clearer.


Matter of fact, I just had a problem in Phobos 2 where a function was 
defined like that and I had to comment out the "ref" for it to work. 
Kept telling me that some array was not an lvalue. The minute I 
commented out the "ref", everything worked like a charm.


Also it makes more sense to me to have separate functions as getters and 
setters. Maybe that's only because I lacking proper training in the art 
of computer programming though.



I suppose you could also try returning a pointer to an associative array
(e.g. with &) in D 1.x.

-[Unknown]

flourish wrote:

Hi,

why does the following code not compile -- or how to declare a (usable)
property of an associative array field?

//
class Test
{
private int[int] _testMap;
public int[int] testMap() {return _testMap;}
}


void main()
{
Test test = new Test();
test.testMap[0] = 1;
}
/

*** Error: test.testMap() is not an lvalue


Regards,
flourish







Re: Error: xxx is not an lvalue

2009-05-02 Thread Tyro[a.c.edwards]

On 5/3/2009 6:36 AM, Denis Koroskin wrote:

On Sun, 03 May 2009 01:02:41 +0400, Tyro[a.c.edwards] 
wrote:


On 5/3/2009 3:44 AM, flourish wrote:

Hi,

why does the following code not compile -- or how to declare a (usable)
property of an associative array field?

//
class Test
{
private int[int] _testMap;
public int[int] testMap() {return _testMap;}
}



testMap() is a getter and can only return the value it is designed to.
You must implement a setter to accomplish what you are trying to di.
Unfortunately I'm not sure how you do that with AAs so I'll leave that
to someone that's a little smarter than I.


[...]


No, you are wrong, testMap works like a property here. I believe,
original code _should_ work. For example, it works if you replace
int[int] with int[].
All the trouble is because of an awful properties implementation in D,
and temporaries not being able to be passed by reference:



Thanks for the clarification.


Re: Error: xxx is not an lvalue

2009-05-02 Thread Tyro[a.c.edwards]

On 5/3/2009 3:44 AM, flourish wrote:

Hi,

why does the following code not compile -- or how to declare a (usable)
property of an associative array field?

//
class Test
{
   private int[int] _testMap;
   public int[int] testMap() {return _testMap;}

 public void opIndexAssign(int val, int ndx){ _testMap[ndx] = val; }

}



testMap() is a getter and can only return the value it is designed to.
You must implement a setter to accomplish what you are trying to do.
Unfortunately I'm not sure how to do it with AAs so I'll leave the
details to someone that's a little smarter than I.

I think that maybe implementing opIndexAssign might do the trick though.
See modifications to Test and main().


void main()
{
   Test test = new Test();

 //test.testMap[0] = 1; // Error: getters cannot be assigned to
 test[0] = 1;

}
/

*** Error: test.testMap() is not an lvalue


Regards,
 flourish







Re: Error: xxx is not an lvalue

2009-05-02 Thread Tyro[a.c.edwards]

On 5/3/2009 3:44 AM, flourish wrote:

Hi,

why does the following code not compile -- or how to declare a (usable)
property of an associative array field?

//
class Test
{
   private int[int] _testMap;
   public int[int] testMap() {return _testMap;}
}



testMap() is a getter and can only return the value it is designed to.
You must implement a setter to accomplish what you are trying to di. 
Unfortunately I'm not sure how you do that with AAs so I'll leave that 
to someone that's a little smarter than I.


I think that maybe implementing opIndexAssign might work for you though:

public void opIndexAssign(int val, int ndx){ _testMap[ndx] = val; }

Then you can simply "test[0] = 1;" to get the desired effect.


void main()
{
   Test test = new Test();
   test.testMap[0] = 1;
}
/

*** Error: test.testMap() is not an lvalue


Regards,
 flourish







std.date Cyclic dependency

2009-03-10 Thread Tyro[a.c.edwards]
Hello everyone,

It's been quite a while but I've kept close watch on the development of things 
here... must say that I am very thankful for all the work everyone has done in 
making D what it is today.

The following code:

 private import std.date;
 void main(){}

generates the runtime error:
 object.Exception: Cyclic dependency in module std.date

courtesy DMD 2.026

any pointers to a quick resolution would be greatly appreciated.

Thanks,
Andrew