Re: Why does the example on page 8 of TDPL work without importing std.algorithm for splitter?

2011-01-04 Thread Lars T. Kyllingstad
On Mon, 03 Jan 2011 17:18:34 -0600, Ellery Newcomer wrote:

 If you're importing some other phobos module, I would guess an instance
 of this bug: http://d.puremagic.com/issues/show_bug.cgi?id=314
 
 On 01/03/2011 10:56 AM, Bryce Watkins wrote:
 However when I use splitter in my code it works without having imported
 std.algorithm.

That's right.  std.string does a public selective import of startsWith() 
and endsWith() from std.algorithm, and bug 314 causes the whole module to 
be imported publically.

314 is a huge, gaping hole in the module system.  AFAIK, it's a high-
priority bug, but also one that is very difficult to fix for some reason.

-Lars


Asian characters are not printed propely in console

2011-01-04 Thread Jun
I'm sorry for posting in the wrong place.

I attached screenshot of my code and the result.

As you can see, Korean letters get changed after compilation.

This problem doesn't happen with user input(from readln() method).

Should I use different type and prefix or suffix similary to C++?
begin 644 캡처.PNG
MB5!.1PT*@h-24...@```5```$.`8]L%0G`7-21T(`KLX
MZ01G04U!``QCPO\804)$A9P``#L,```[#`=OJ0``#$^241!
M5'A[7UMLQS'=w...@?\u_8%VIQ';)Y41.`1=TE56.R^6J5-W*ASL4$DE
m...@w+kw+a;6%3M!0[BBQ8ET5XL+DA)MS:`(+2QN*\$H%D2?`5`$NKT
MTS//S#,]W=/=\[([NWM0M86[.ST]/:=/GS[]=$_/1.$?$``0``(]([`I/
MD2$0``)`...@hbM(``2``!`8``(ZP@(d...@``2`0MQG6\K-9T!O8$YFI[
M,E3I0'EO_Y\z+k[rh...@`@0$1:6N`Y:G]:SJ5+SSKGX,YA-MQ/RUP+7
m...@n^_h#0hnl@!:(9`DKEU6]5FS'PJFJ%-T)1^U\*F39$Y/M*QVE)[$CT
MZ/M,Y^6P:*T\ES7$^1M693%BRF7(K\_G;RJ[4S?R(0IW=4S7E]47
MG/+OXO]*_E::;0Uj...@.?VKD^-Y]SK5Q_XNI(k...@z/JSS;)6=VO5,G`S
M0*`C`DGBRMB8:L9LESC-CDPDI_4EH6(!;'0N_R_...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y,;@`$``JXT`GM!:
m[?i#z8$...@i`l:YVBL#77%XZ\CK4$4p...@`@5$B`'$=9;6...@4$``*PZ`DGB
mvk2gz...@?(#`2``!/I$(%I^[ph\eh2`...@_,V9=`G0_KN=VFRQQ#A!8
m...@kfm:L8KBSW9=MQ=+I`N=W6=#Q#`FG[YW;zx...@l(M$``XMHM'?
M(MRE9...@241]3e7$lym^z=9X0`CQLDE`X(#(X`Q'5PB!=Y`8KG6MQM04V
M65RMX!S762EXEHKBL!BNMB\MT=K7W*KNJ8YH3[1;ITT?^L^F3JE+,%[^H
MOOXS/Z.^_L47U;m?^v7s]zfow...@v*j-=I#]MBVE9K^:8^0U5+ZK+ZGI
M]*740,RDN#95Qrz[1tq...@b6qg9V?TH;S2O62-[ZF3GWF,YF@
MYD+VW1=%$G*IL(JEWY(!;?#`B9VF\=BY?^NNRH?+JH\^W#SB+8HMT0!5
m...@99U-,TX$)!#M3\EC=T3D/5KK(4BP;G:46D6GN.ME]TO\5K;+39^
M7.+*U][WB[[40/UWVAS]G4(4*Y!E!)7']S^K2\*XFD`J:#,-#4LP'DT
mk0kp...@^72y@^[UBC;:a_5m6*y]55...@d$@161EQI]GOJ7S[6EUZ*S%
M1`JNMDHUI]3D+)NZVQ:O9813(?`^O+/!+8J]FZ'2P)SRB\+ZKOLJ`:(?NB
MJFBKJ=18`N7F3BAU6SKE0';.E%)\:4c^z...@akeg...@=15X\W9QRJ

Re: Asian characters are not printed propely in console

2011-01-04 Thread Vladimir Panteleev

On Tue, 04 Jan 2011 11:47:32 +0200, Jun bli...@naver.com wrote:


Should I use different type and prefix or suffix similary to C++?


Place the following code anywhere at the top level in your program:

version(Windows)
{
import std.c.windows.windows : SetConsoleCP, SetConsoleOutputCP;
static this()
{
SetConsoleCP(65001);
SetConsoleOutputCP(65001);
}
}

This code should really be in the standard library, I think.

--
Best regards,
 Vladimirmailto:vladi...@thecybershadow.net


terminology: l-value r-value

2011-01-04 Thread spir
Hello,

I'm bluffed by the 2 terms l-value  r-value used in C-line language common 
terminologies. I think I guess what they mean, but I don't understand the need 
for such absconse idioms. Why not:
l-value - variable
r-value - value (or expression)
?

I guess (*p) is considered an l-value. Indeed, it's a special way of denoting a 
variable, matching the special case of a pointer. If correct, this requires 
slightly extending the notion of variable (and/or of identifier).
On the r-value side, I cannot find anything that makes it a distinct concept 
from the one of value, or of expression.

Explanations welcome, thank you,
Denis
-- -- -- -- -- -- --
vit esse estrany ☣

spir.wikidot.com



Re: terminology: l-value r-value

2011-01-04 Thread Pelle

On 01/04/2011 02:55 PM, spir wrote:

Hello,

I'm bluffed by the 2 terms l-value  r-value used in C-line language common 
terminologies. I think I guess what they mean, but I don't understand the need for such absconse 
idioms. Why not:
l-value-  variable
r-value-  value (or expression)
?

I guess (*p) is considered an l-value. Indeed, it's a special way of denoting a 
variable, matching the special case of a pointer. If correct, this requires 
slightly extending the notion of variable (and/or of identifier).
On the r-value side, I cannot find anything that makes it a distinct concept 
from the one of value, or of expression.

Explanations welcome, thank you,
Denis
-- -- -- -- -- -- --
vit esse estrany ☣

spir.wikidot.com



rvalue is easier than value-not-bound-to-a-memory-address.

lvalue is easier than value-with-memory-address.

Both lvalues and rvalues are values, both can be expressions, and 
lvalues doesn't have to be variables.


Perhaps a better terminology could have been chosen, but changing them 
doesn't provide real benefits, as far as I can tell.


Re: terminology: l-value r-value

2011-01-04 Thread Steven Schveighoffer

On Tue, 04 Jan 2011 08:55:07 -0500, spir denis.s...@gmail.com wrote:


Hello,

I'm bluffed by the 2 terms l-value  r-value used in C-line language  
common terminologies. I think I guess what they mean, but I don't  
understand the need for such absconse idioms. Why not:

l-value - variable
r-value - value (or expression)
?

I guess (*p) is considered an l-value. Indeed, it's a special way of  
denoting a variable, matching the special case of a pointer. If correct,  
this requires slightly extending the notion of variable (and/or of  
identifier).
On the r-value side, I cannot find anything that makes it a distinct  
concept from the one of value, or of expression.


Explanations welcome, thank you,
Denis


lvalue stands for left value, rvalue stands for right value.  They  
describe which side of the equation they are on:


lvalue = rvalue;

Why these terms instead of something more natural?  Well, I have no idea  
:)  If I were to guess, it would be that no natural term could exactly  
describe the meaning, and also that using natural terms are subjective.   
There's no mistaking what lvalue and rvalue mean becausey they are defined  
by the language itself.


I'm sure Walter probably knows the origin, l and r values are really  
compiler terms, and he's been writing compilers for a long time.


-Steve


Re: Why does the example on page 8 of TDPL work without importing std.algorithm for splitter?

2011-01-04 Thread Bryce Watkins

On 4/01/2011 9:26 p.m., Lars T. Kyllingstad wrote:

On Mon, 03 Jan 2011 17:18:34 -0600, Ellery Newcomer wrote:


If you're importing some other phobos module, I would guess an instance
of this bug: http://d.puremagic.com/issues/show_bug.cgi?id=314

On 01/03/2011 10:56 AM, Bryce Watkins wrote:

However when I use splitter in my code it works without having imported
std.algorithm.


That's right.  std.string does a public selective import of startsWith()
and endsWith() from std.algorithm, and bug 314 causes the whole module to
be imported publically.

314 is a huge, gaping hole in the module system.  AFAIK, it's a high-
priority bug, but also one that is very difficult to fix for some reason.

-Lars


Thanks now I understand, this also means that the example on page 8 only 
works because of bug 314, and should this bug ever be fixed then the 
example code will break. Therefore it really should include an import of 
std.algorithm explicitly for both clarity and long term reliability.


Bryce.


Re: terminology: l-value r-value

2011-01-04 Thread Manfred_Nowak
Steven Schveighoffer wrote:

 They describe which side of the equation they are on

arg, no! please replace equation by assignExpression.

-manfred


Re: terminology: l-value r-value

2011-01-04 Thread Steven Schveighoffer
On Tue, 04 Jan 2011 12:56:53 -0500, Manfred_Nowak svv1...@hotmail.com  
wrote:



Steven Schveighoffer wrote:


They describe which side of the equation they are on


arg, no! please replace equation by assignExpression.


please replace arg with argh!

;)

But whatever floats your boat.

-Steve


Re: terminology: l-value r-value

2011-01-04 Thread spir
On Tue, 4 Jan 2011 17:56:53 + (UTC)
Manfred_Nowak svv1...@hotmail.com wrote:

  They describe which side of the equation they are on  
 
 arg, no! please replace equation by assignExpression.

lol, great! this is one of the reasons why in my dream language, assignment 
would be denoted by any other sign *but* =.

Denis
-- -- -- -- -- -- --
vit esse estrany ☣

spir.wikidot.com



Re: terminology: l-value r-value

2011-01-04 Thread Manfred_Nowak
Steven Schveighoffer wrote:

 please replace

done. :-)

-manfred


joining multicast groups with std.socket

2011-01-04 Thread Peter Ryan
I am trying to listen to a multicast group using the std.socket library. I
have looked at the documentation but I do not see a way to join a multicast
group. The code I have so far is pasted below. I am looking for
the IP_ADD_MEMBERSHIP socket option (along the lines of
http://www.cs.unc.edu/~jeffay/dirt/FAQ/comp249-001-F99/mcast-socket.html)
and can't find within the library.

Let's assume I am trying to listen to 225.0.0.37/12345

Can someone help me with a snippet on some d code that will do this?

I appreciate the help!

Peter



auto socket = new UdpSocket();
auto address = new InternetAddress(12345);
socket.bind(address);
auto multicastAddress = new InternetAddress(225.0.0.37);

/// The below naturally does not work and I can't seem to find

// How do I join the multicast address above?

byte[256] buffer;
int read = socket.receiveFrom(buffer);
printf(Received bytes %i, read);
return 0;