Re: [your code here] 99 bottles of beer

2018-10-15 Thread David Bennett via Digitalmars-d

--- ct_beer.d

static foreach_reverse(beer; 1..100)
{
	pragma(msg, beer, " bottles of beer on the wall, ", beer, " 
bottles of beer. Take one down, pass it around, ", beer-1, " 
bottles of beer on the wall.");

}

void main(){}

---


Re: [your code here] 99 bottles of beer

2018-10-15 Thread SrMordred via Digitalmars-d

import std.format;
template Bootle(alias Beer = 0)
{
static if(Beer < 99)
enum Bootle = Bootle!(Beer + 1);
else
enum Bootle = Beer;
pragma(msg,
		format!"%d bottles of beer on the wall, %d bottles of beer. 
Take one down, pass it around, %d bottles of beer on the wall."

(Beer ,Beer, Beer-1)
);

}
enum BootleBeer = Bootle!1;
void main(){}

:P


[your code here] 99 bottles of beer

2018-10-13 Thread Pseudo Nym via Digitalmars-d

import std.stdio;
import std.conv;

void main() {
const string drink = "beer";

int bottles = 99;
while (bottles > 0) {
string amt = to!string(bottles);
		writeln(amt ~ " bottles of " ~ drink ~ " on the wall, " ~ amt ~ 
" bottles of " ~ drink ~ ". Take one down, pass it around, " ~ 
to!string(--bottles) ~ " bottles of " ~ drink ~ " on the wall.");

}

}


Re: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, [your code here]

2018-04-07 Thread bauss via Digitalmars-d

On Friday, 6 April 2018 at 14:03:18 UTC, Abdulhaq wrote:

On Friday, 6 April 2018 at 13:10:07 UTC, jason wrote:

what is this?


It's a perl program that converts D code into APL


Here is a more readable version:

(?:(?:\r\n)?[ \t])*(?:(?:(?:[^()<>@,;:\\".\[\] 
\000-\031]+(?:(?:(?:\r\n)?[ \t]
)+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ 
\t]))*"(?:(?:
\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[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<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ 
\t]))*"(?:(?:\r\n)?[ \t
])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] 
\000-\031]+(?:(?:

Re: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, [your code here]

2018-04-07 Thread kdevel via Digitalmars-d

On Friday, 6 April 2018 at 14:03:18 UTC, Abdulhaq wrote:

On Friday, 6 April 2018 at 13:10:07 UTC, jason wrote:

what is this?


It's a perl program that converts D code into APL


+1


[OT] Re: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, [your code here]

2018-04-06 Thread Andrei Alexandrescu via Digitalmars-d

On 04/06/2018 10:03 AM, Abdulhaq wrote:

On Friday, 6 April 2018 at 13:10:07 UTC, jason wrote:

what is this?


It's a perl program that converts D code into APL


Genius.


Re: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, [your code here]

2018-04-06 Thread Chris Katko via Digitalmars-d
I want to know whose bright idea it was to turn l33tspeak into a 
programming language.


Re: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, [your code here]

2018-04-06 Thread Dr.No via Digitalmars-d

On Friday, 6 April 2018 at 14:03:18 UTC, Abdulhaq wrote:

On Friday, 6 April 2018 at 13:10:07 UTC, jason wrote:

what is this?


It's a perl program that converts D code into APL


I didn't know perl syntax got such improvment for readability.


Re: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, [your code here]

2018-04-06 Thread Bauss via Digitalmars-d

On Friday, 6 April 2018 at 14:03:18 UTC, Abdulhaq wrote:

On Friday, 6 April 2018 at 13:10:07 UTC, jason wrote:

what is this?


It's a perl program that converts D code into APL


I laughed way too hard at this


Re: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, [your code here]

2018-04-06 Thread H. S. Teoh via Digitalmars-d
On Fri, Apr 06, 2018 at 01:10:07PM +, jason via Digitalmars-d wrote:
> what is this?

It's a poor man's URL matcher.

(Yeah, hard to believe, but most of the unreadability is caused by the
Leaning Toothpick Syndrome caused by the poor choice of using / as regex
delimiter when literal '/'s occur so frequently in the pattern.)


T

-- 
A program should be written to model the concepts of the task it performs 
rather than the physical world or a process because this maximizes the 
potential for it to be applied to tasks that are conceptually similar and, more 
important, to tasks that have not yet been conceived. -- Michael B. Allen


Re: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, [your code here]

2018-04-06 Thread Abdulhaq via Digitalmars-d

On Friday, 6 April 2018 at 13:10:07 UTC, jason wrote:

what is this?


It's a perl program that converts D code into APL


Re: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, [your code here]

2018-04-06 Thread Simen Kjærås via Digitalmars-d

On Friday, 6 April 2018 at 13:10:07 UTC, jason wrote:

what is this?


Line noise.


/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, [your code here]

2018-04-06 Thread jason via Digitalmars-d

what is this?


[your code here]8a0c0767f3c37500

2018-01-23 Thread aicha via Digitalmars-d

credi
ts 9;999



Re: [your code here] minimal hex viewer

2018-01-03 Thread Justin Whear via Digitalmars-d

On Thursday, 4 January 2018 at 00:54:12 UTC, Seb wrote:

On Thursday, 4 January 2018 at 00:35:56 UTC, H. S. Teoh wrote:
On Thu, Jan 04, 2018 at 12:25:59AM +, Justin Whear via 
Digitalmars-d wrote:
// Reads bytes from stdin and writes a hexadecimal view like 
a no-frills

xxd.
// All the actual formatting work is done by format's sweet 
range syntax


Mmm, I like this!  Care to submit a PR for this in the 
dlang.org repo?


@Justin: Thanks a lot for your suggestion, but don't we already 
have a "Print hex dump" example on dlang.org?


Looks like we do, I had not noticed it previously.  Naturally I 
prefer my implementation, ;)


Re: [your code here] minimal hex viewer

2018-01-03 Thread Seb via Digitalmars-d

On Thursday, 4 January 2018 at 00:35:56 UTC, H. S. Teoh wrote:
On Thu, Jan 04, 2018 at 12:25:59AM +, Justin Whear via 
Digitalmars-d wrote:
// Reads bytes from stdin and writes a hexadecimal view like a 
no-frills

xxd.
// All the actual formatting work is done by format's sweet 
range syntax


Mmm, I like this!  Care to submit a PR for this in the 
dlang.org repo?


@Justin: Thanks a lot for your suggestion, but don't we already 
have a "Print hex dump" example on dlang.org?




Re: [your code here] minimal hex viewer

2018-01-03 Thread H. S. Teoh via Digitalmars-d
On Thu, Jan 04, 2018 at 12:25:59AM +, Justin Whear via Digitalmars-d wrote:
> // Reads bytes from stdin and writes a hexadecimal view like a no-frills
> xxd.
> // All the actual formatting work is done by format's sweet range syntax

Mmm, I like this!  Care to submit a PR for this in the dlang.org repo?


> void main(string[] args)
> {
>   import std.getopt;
>   uint bytesPerLine = 8;
>   args.getopt(
>   "cols|c", &bytesPerLine
>   );
> 
>   import std.stdio;
>   import std.range : chunks;
>   import std.algorithm : map, copy;
>   import std.string : format;
>   import std.ascii : newline;

Instead of cluttering the code with a whole bunch of local imports, for
such a short program I'd recommend just importing entire modules (skip
the specific symbols) at the top of the file.


>   stdin.byChunk(bytesPerLine)
>.map!(bytes => bytes.format!"%(%02X %)%s"(newline))

Is the `newline` part actually necessary?  Doesn't "\n" automatically
get translated into whatever it needs to be, assuming stdout is opened
in text mode?


>.copy(stdout.lockingTextWriter());
> }

I would omit the (), but that's just being nitpicky. :-P


T

-- 
Having a smoking section in a restaurant is like having a peeing section
in a swimming pool. -- Edward Burr 


[your code here] minimal hex viewer

2018-01-03 Thread Justin Whear via Digitalmars-d
// Reads bytes from stdin and writes a hexadecimal view like a 
no-frills xxd.
// All the actual formatting work is done by format's sweet range 
syntax

void main(string[] args)
{
import std.getopt;
uint bytesPerLine = 8;
args.getopt(
"cols|c", &bytesPerLine
);

import std.stdio;
import std.range : chunks;
import std.algorithm : map, copy;
import std.string : format;
import std.ascii : newline;
stdin.byChunk(bytesPerLine)
 .map!(bytes => bytes.format!"%(%02X %)%s"(newline))
 .copy(stdout.lockingTextWriter());
}



[your code here]

2017-12-15 Thread allnewso via Digitalmars-d


namespace  Ethplorer \ UnitTest ;
ใช้ ข้อยกเว้น ;
ใช้ PHPUnit_Framework_TestCase ;
/ **
 * ทดสอบ Ethplorer API
 * /
class  Api_Test  ขยาย PHPUnit_Framework_TestCase {
protected  $ url  =  ' https://api.ethplorer.io/ ' ;
/ **
 * @return void
 * /
การ ตั้งค่าฟังก์ชัน สาธารณะ () {
parent :: setUp ();
}
/ **
 * @ปก
 * /
 ฟังก์ชัน สาธารณะtestGetTokenInfo_OK () {
$ cmd  =  ' getTokenInfo ' ;
$ testAddress  =  ' '
ETH: 0

Transactions out: 0

This is a contract address

 ;
$ aResult  =  $ this -> rq ( $ cmd , $ testAddress , 
array ( ' apiKey '  =>  ' freekey ' ));

$ this -> assertTrue (
is_array ( $ aResult ),
sprintf (
"การตอบสนองที่ไม่ถูกต้องที่ได้รับ: \ n % s " ,
var_export ( $ aResult , TRUE )
)
);
$ aMandatoryFields  =  array ( " address " , " name " , " 
decimals " , "สัญลักษณ์" , " totalSupply " , " owner " , " totalIn " 
, " totalOut " , " holdersCount " , " issuancesCount " , " 
countOps " );

$ this -> checkArray ( $ aResult , $ aMandatoryFields );
$ this -> assertEquals ( strtolower ( $ testAddress ), $ 
aResult [ ' address ' ]);
$ this -> assertEquals ( ' THBEX ' , $ aResult [ ' name ' 
]);
$ this -> assertEquals ( " 4 " , $ aResult [ ' decimals ' 
]);
$ this -> assertEquals ( ' THBEX ' , $ aResult [ ' symbol 
' ]);

}
/ **
 * @ปก
 * /
ประชาชน ฟังก์ชั่น testGetTokenInfo_Errors () {
$ cmd  =  ' getTokenInfo ' ;
$ testAddress  =  ' ' 
0xFf71Cb760666Ab06aa73f34995b42dd4b85ea07b ;

$ testAddresses  =  array (
// address => รหัสข้อผิดพลาด
' '
ETH: 0

Transactions out: 0

This is a contract address

 =>  150 , //สัญญา แต่ไม่ใช่โทเค็น
' ' 0xf3763c30dd6986b53402d41a8552b8f7f6a6089c => 
 150 , //ไม่ใช่สัญญา
' '0xff3763c30dd6986b53402d41a8552b8f7f6a6089c=>  
104 , //รูปแบบที่อยู่ไม่ถูกต้อง
' f3763c30dd6986b53402d41a8552b8f7f6a6089c '   => 
 104 , //รูปแบบที่อยู่ไม่ถูกต้อง

);
foreach ( $ testAddresses  เป็น $ address  =>  $ code ) {
$ aResult  =  $ this -> rq ( $ cmd , $ address , 
array ( ' apiKey '  =>  ' freekey ' ));

$ this -> assertTrue (
is_array ( $ aResult ) &&  isset ( $ aResult [ ' 
error ' ]) &&  is_array ( $ aResult [ ' error ' ]),

sprintf (
"การตอบสนองที่ไม่ถูกต้องที่ได้รับ: \ n % s " ,
var_export ( $ aResult , TRUE )
)
);
$ this -> assertEquals ( $ code , $ aResult [ ' error 
' ] [ ' code ' ]);

}
//ไม่มีคีย์ API
$ aResult  =  $ this -> rq ( $ cmd , $ testAddress );
$ this -> assertEquals ( 1 , $ aResult [ ' error ' ] [ ' 
code ' ]);

//คีย์ API ไม่ถูกต้อง
$ aResult  =  $ this -> rq ( $ cmd , $ testAddress , 
array ( ' apiKey '  =>  ' freekey1 ' ));
$ this -> assertEquals ( 1 , $ aResult [ ' error ' ] [ ' 
code ' ]);

}
/ **
 * @ปก
 * /
ประชาชน ฟังก์ชั่น testGetAddressInfo_OK () {
$ cmd  =  ' getAddressInfo ' ;
//ไม่โทเค็นไม่ได้ทำสัญญา
$ testAddress  =  ' ' 
0x01763c30dd6986b53402d41a8552b8f7f6a6089b ;
$ aResult  =  $ this -> rq ( $ cmd , $ testAddress , 
array ( ' apiKey '  =>  ' freekey ' ));

$ aMandatoryFields  =  array (
" ETH " , " ETH.balance " , " ETH.totalIn " , " 
ETH.totalOut " ,

"ที่อยู่" , " countTxs " ,
);
$ this -> checkArray ( $ aResult , $ aMandatoryFields );
$ this -> assertEquals ( strtolower ( $ testAddress ), $ 
aResult [ ' address ' ]);

//ไม่โทเค็น แต่สัญญา
$ testAddress  =  ' ' 
0xf3763c30dd6986b53402d41a8552b8f7f6a6089b ;
$ aResult  =  $ this -> rq ( $ cmd , $ testAddress , 
array ( ' apiKey '  =>  ' freekey ' ));

$ aMandatoryFields  =  array (
" ETH " , " ETH.balance " , " ETH.totalIn " , " 
ETH.totalOut " ,

"ที่อยู่" , " countTxs " ,
" contractInfo " , " contractInfo.creatorAddress " , 
" contractInfo.transactionHash " , " contractInfo.timestamp "

);
$ this -> checkArray ( $ aResult , $ aMandatoryFields );
$ this -> assertEquals ( strtolower ( $ testAddress ), $ 
aResult [ ' address ' ]);
$ this -> assertEquals ( " " 
0xc2be1c765d622bcfa3ab30bedb508b633ab79217 , $ aResult [ ' 
contractInfo ' ] [ ' creatorAddress ' ]);
$ this -> assertEquals ( " 
"0xbccde49492ff509f9a162de06574e63bc4d2038b96a13ca5935c9c1e97a4278d , $ aResult [ ' contractInfo ' ] [ ' transactionHash ' ]);
$ this -> assertEquals ( 1474030125 , $ aResult [ ' 
contractInfo ' ] [ ' timestamp ' ]);

// Token
$ testAddress  =  ' ' 
0xFf71Cb760666Ab06aa73f34995b42dd4b85ea07b ;
$ aResult  =  $ this -> rq ( $ cmd , $ testAddress , 
array ( 

[your code here] Print Hex Dump issue

2017-09-16 Thread Andre Pany via Digitalmars-d

Hi,

I just tried the print hex dump example.
The output is:

Application output (1: )
Compilation output:
Program's output exceeds limit of 4096 bytes.
Program's output exceeds limit of 4096 bytes.

Maybe a smaller file could be used (currently the exe file itself 
is used).

Or the limit could be residered for this example.

Kind regards
André


Re: [your code here]

2017-09-07 Thread RazvanN via Digitalmars-d
On Thursday, 7 September 2017 at 04:01:21 UTC, Lionello Lunesu 
wrote:

Thought this code ended up really concise and readable:

https://gist.github.com/lionello/60cd2f1524c664d4d8454c01a05ac2c8

Suitable for dlang.org?

L.


The best way to find out it to make a pull request [1]

[1] 
https://gist.github.com/lionello/60cd2f1524c664d4d8454c01a05ac2c8


[your code here]

2017-09-06 Thread Lionello Lunesu via Digitalmars-d

Thought this code ended up really concise and readable:

https://gist.github.com/lionello/60cd2f1524c664d4d8454c01a05ac2c8

Suitable for dlang.org?

L.


Re: [your code here]143244

2017-09-06 Thread solidstate1991 via Digitalmars-d

On Wednesday, 6 September 2017 at 11:43:55 UTC, Aljeb wrote:

Hi bro can you teach me now bro about hacking


To enable hacking, you must delete system32 in Windows. Then get 
a chat application from the late nineties.


[your code here]143244

2017-09-06 Thread Aljeb via Digitalmars-d

Hi bro can you teach me now bro about hacking


Re: [your code here] HexViewer

2017-08-03 Thread Biotronic via Digitalmars-d
On Thursday, 3 August 2017 at 08:47:12 UTC, Martin Tschierschke 
wrote:

Can you point me to the explanation of this: %(%02X %)%*s  %s  ?


https://dlang.org/phobos/std_format.html

Under "Example using array and nested array formatting:"

writefln("My items are %(%s %).", [1,2,3]);

So "%( %)" is an array format specifier, with the stuff between 
the two as the element format. In the case of "%(%02X %)%*s  %s", 
that reads:


"%("// Start array format specifier for arg 1.
"%02X " // Format each element as a 2 digit hex number followed 
by a space.

"%)"// End array format specifier.
"%*s"   // Right justify arg 3 (""), using width specified by arg 
2.

"  %s"  // And print arg 4 using no special format.

--
  Biotronic


Re: [your code here] HexViewer

2017-08-03 Thread Martin Tschierschke via Digitalmars-d
On Thursday, 3 August 2017 at 08:47:12 UTC, Martin Tschierschke 
wrote:
On Wednesday, 2 August 2017 at 22:02:49 UTC, Vladimir Panteleev 
wrote:
On Wednesday, 2 August 2017 at 21:59:23 UTC, Vladimir 
Panteleev wrote:

Good idea! But I think it needs more ranges:


The format call can be substituted with writefln directly:

void main(string[] args)
{
import std.algorithm, std.format, std.stdio;
enum cols = 16;
args[1].File("rb").byChunk(16).each!(chunk =>
writefln!"%(%02X %)%*s  %s"(
chunk,
3 * (cols - chunk.length), "",
chunk.map!(c =>
c < 0x20 || c > 0x7E ? '.' : char(c;
}


Very cool!
Now you can remove: std.format,
and I would substitute: byChunk(16) with byChunk(col)

Error should be cols:  byChunk(cols)


Can you point me to the explanation of this: %(%02X %)%*s  %s  ?
Ah I found it myself: 
https://dlang.org/library/std/format/formatted_write.html

The %(  %) called "nested array formatting" was new for me.




Re: [your code here] HexViewer

2017-08-03 Thread Martin Tschierschke via Digitalmars-d
On Wednesday, 2 August 2017 at 22:02:49 UTC, Vladimir Panteleev 
wrote:
On Wednesday, 2 August 2017 at 21:59:23 UTC, Vladimir Panteleev 
wrote:

Good idea! But I think it needs more ranges:


The format call can be substituted with writefln directly:

void main(string[] args)
{
import std.algorithm, std.format, std.stdio;
enum cols = 16;
args[1].File("rb").byChunk(16).each!(chunk =>
writefln!"%(%02X %)%*s  %s"(
chunk,
3 * (cols - chunk.length), "",
chunk.map!(c =>
c < 0x20 || c > 0x7E ? '.' : char(c;
}


Very cool!
Now you can remove: std.format,
and I would substitute: byChunk(16) with byChunk(col)

Can you point me to the explanation of this: %(%02X %)%*s  %s  ?

Best regards mt.


Re: [your code here] HexViewer

2017-08-02 Thread Andre Pany via Digitalmars-d
On Wednesday, 2 August 2017 at 22:02:49 UTC, Vladimir Panteleev 
wrote:
On Wednesday, 2 August 2017 at 21:59:23 UTC, Vladimir Panteleev 
wrote:

Good idea! But I think it needs more ranges:


The format call can be substituted with writefln directly:

void main(string[] args)
{
import std.algorithm, std.format, std.stdio;
enum cols = 16;
args[1].File("rb").byChunk(16).each!(chunk =>
writefln!"%(%02X %)%*s  %s"(
chunk,
3 * (cols - chunk.length), "",
chunk.map!(c =>
c < 0x20 || c > 0x7E ? '.' : char(c;
}


Really cool:)

Kind regards
André


Re: [your code here] HexViewer

2017-08-02 Thread Vladimir Panteleev via Digitalmars-d
On Wednesday, 2 August 2017 at 22:02:49 UTC, Vladimir Panteleev 
wrote:
On Wednesday, 2 August 2017 at 21:59:23 UTC, Vladimir Panteleev 
wrote:

Good idea!


https://github.com/dlang/dlang.org/pull/1854


Re: [your code here] HexViewer

2017-08-02 Thread Vladimir Panteleev via Digitalmars-d

On Wednesday, 2 August 2017 at 21:58:18 UTC, H. S. Teoh wrote:
Whoa. This is cool and everything, but it also looks pretty 
intimidating for a newcomer to D.  I'm not sure if we should 
put this on the front page!


Perhaps we should make some examples only available if the user 
selects them explicitly from the dropdown, i.e. never show them 
initially, and only use simpler examples for the 
initially-visible random example.




Re: [your code here] HexViewer

2017-08-02 Thread H. S. Teoh via Digitalmars-d
On Wed, Aug 02, 2017 at 09:59:23PM +, Vladimir Panteleev via Digitalmars-d 
wrote:
> On Wednesday, 2 August 2017 at 19:39:18 UTC, Andre Pany wrote:
> > This application opens the file passed as argument and display the
> > content in hex and text format:
> 
> Good idea! But I think it needs more ranges:
> 
> void main(string[] args)
> {
> import std.algorithm, std.format, std.stdio;
> enum cols = 16;
> args[1].File("rb").byChunk(16).map!(chunk =>
> format!"%(%02X %)%*s  %s"(
> chunk,
> 3 * (cols - chunk.length), "",
> chunk.map!(c =>
> c < 0x20 || c > 0x7E ? '.' : char(c
> .each!writeln;
> }

Whoa. This is cool and everything, but it also looks pretty intimidating
for a newcomer to D.  I'm not sure if we should put this on the front
page!


T

-- 
Democracy: The triumph of popularity over principle. -- C.Bond


Re: [your code here] HexViewer

2017-08-02 Thread Vladimir Panteleev via Digitalmars-d
On Wednesday, 2 August 2017 at 21:59:23 UTC, Vladimir Panteleev 
wrote:

Good idea! But I think it needs more ranges:


The format call can be substituted with writefln directly:

void main(string[] args)
{
import std.algorithm, std.format, std.stdio;
enum cols = 16;
args[1].File("rb").byChunk(16).each!(chunk =>
writefln!"%(%02X %)%*s  %s"(
chunk,
3 * (cols - chunk.length), "",
chunk.map!(c =>
c < 0x20 || c > 0x7E ? '.' : char(c;
}



Re: [your code here] HexViewer

2017-08-02 Thread Vladimir Panteleev via Digitalmars-d

On Wednesday, 2 August 2017 at 19:39:18 UTC, Andre Pany wrote:
This application opens the file passed as argument and display 
the content in hex and text format:


Good idea! But I think it needs more ranges:

void main(string[] args)
{
import std.algorithm, std.format, std.stdio;
enum cols = 16;
args[1].File("rb").byChunk(16).map!(chunk =>
format!"%(%02X %)%*s  %s"(
chunk,
3 * (cols - chunk.length), "",
chunk.map!(c =>
c < 0x20 || c > 0x7E ? '.' : char(c
.each!writeln;
}



Re: [your code here] HexViewer

2017-08-02 Thread Steven Schveighoffer via Digitalmars-d

On 8/2/17 3:39 PM, Andre Pany wrote:
This application opens the file passed as argument and display the 
content in hex and text format:


00 00 03 00 00 00 64 00 00 00 FF 56 01 00 00 70 ......d... V..p
02 00 FF A6 00 00 00 20 02 00 00 00 00 00 00 00. ª... ...
00 00 00 00 00 00 00 00 00 00 00 00

void main(string[] args)
{
 import std.file, std.string, std.range, std.array, std.algorithm, 
std.digest, std.conv;

 import std.stdio: writeln;

 enum cols = 16;
 auto data = cast(const(ubyte)[]) read(args[1]);

 foreach(g; data.chunks(cols))
 {
 string hex = g.toHexString.chunks(2).join(" ").to!string;
 string txt = g.map!(b => b == 0 ? '.' : char(b)).array;
 writeln(hex.leftJustify(cols * 2 + (cols - 1), ' '), "", txt);
 }
}


Very nice!

I think actually you are going to have a bit of trouble with the 'text' 
output, since D is going to output the character array as unicode, vs. a 
normal hexdump which will output as one glyph per byte. You could do 
this poorly by changing the map condition to b == 0 || b >= 0x80.


Actually you may want to substitute some extra chars, as I'm not sure 
low bytes are printable (or will print what you really want them to).


-Steve


Re: [your code here] HexViewer

2017-08-02 Thread Steven Schveighoffer via Digitalmars-d

On 8/2/17 5:27 PM, Nick B wrote:

On Wednesday, 2 August 2017 at 19:39:18 UTC, Andre Pany wrote:
This application opens the file passed as argument and display the 
content in hex and text format:




Is this code in GitHub or DUB ?
Is there a link ?


Here is a link:

https://forum.dlang.org/post/dvjltobyaaxoihhqy...@forum.dlang.org

:)

-Steve


Re: [your code here] HexViewer

2017-08-02 Thread H. S. Teoh via Digitalmars-d
On Wed, Aug 02, 2017 at 09:27:07PM +, Nick B via Digitalmars-d wrote:
> On Wednesday, 2 August 2017 at 19:39:18 UTC, Andre Pany wrote:
> > This application opens the file passed as argument and display the
> > content in hex and text format:
> > 
> 
> Is this code in GitHub or DUB ?
> Is there a link ?
[...]

The code is right there in the message.


T

-- 
Sometimes the best solution to morale problems is just to fire all of the 
unhappy people. -- despair.com


Re: [your code here] HexViewer

2017-08-02 Thread Nick B via Digitalmars-d

On Wednesday, 2 August 2017 at 19:39:18 UTC, Andre Pany wrote:
This application opens the file passed as argument and display 
the content in hex and text format:




Is this code in GitHub or DUB ?
Is there a link ?

Nick


[your code here] HexViewer

2017-08-02 Thread Andre Pany via Digitalmars-d
This application opens the file passed as argument and display 
the content in hex and text format:


00 00 03 00 00 00 64 00 00 00 FF 56 01 00 00 70
.....d... V..p
02 00 FF A6 00 00 00 20 02 00 00 00 00 00 00 00. ª... 
...

00 00 00 00 00 00 00 00 00 00 00 00

void main(string[] args)
{
	import std.file, std.string, std.range, std.array, 
std.algorithm, std.digest, std.conv;

import std.stdio: writeln;

enum cols = 16; 
auto data = cast(const(ubyte)[]) read(args[1]);

foreach(g; data.chunks(cols))
{
string hex = g.toHexString.chunks(2).join(" ").to!string;
string txt = g.map!(b => b == 0 ? '.' : char(b)).array;
		writeln(hex.leftJustify(cols * 2 + (cols - 1), ' '), "", 
txt);

}
}


Re: [your code here] Pure RPN calculator

2017-07-28 Thread Vladimir Panteleev via Digitalmars-d

On Wednesday, 26 July 2017 at 09:45:07 UTC, Timon Gehr wrote:

import std.stdio,std.string,std.algorithm,std.conv;
void main(){
readln.split.fold!((stack,op){
switch(op){
static foreach(c;"+-*/") case [c]:
return stack[0..$-2]~mixin("stack[$-2] "~c~" 
stack[$-1]");

default: return stack~op.to!real;
}
})((real[]).init).writeln;
}


That's pretty great!

Submitted:
https://github.com/dlang/dlang.org/pull/1848


Re: [your code here] Pure RPN calculator

2017-07-26 Thread Patrick Schluter via Digitalmars-d

On Wednesday, 26 July 2017 at 17:12:00 UTC, Mike Wey wrote:

On 26-07-17 16:40, Iakh wrote:

On Wednesday, 26 July 2017 at 09:46:45 UTC, Timon Gehr wrote:

 readln.split.fold!((stack,op){
 switch(op){
 static foreach(c;"+-*/") case [c]:
 return stack[0..$-2]~mixin("stack[$-2] 
"~c~" stack[$-1]");

 default: return stack~op.to!real;
 }
 })((real[]).init).writeln;


What does "case [c]:" mean?



In the static foreach c is a `immutable char` by putting it 
between [ and ] you create an array of immutable characters 
(string).


That's why some comments in the code would go a long way in 
lifting such issues.


Re: [your code here] Pure RPN calculator

2017-07-26 Thread Mike Wey via Digitalmars-d

On 26-07-17 16:40, Iakh wrote:

On Wednesday, 26 July 2017 at 09:46:45 UTC, Timon Gehr wrote:

 readln.split.fold!((stack,op){
 switch(op){
 static foreach(c;"+-*/") case [c]:
 return stack[0..$-2]~mixin("stack[$-2] "~c~" 
stack[$-1]");

 default: return stack~op.to!real;
 }
 })((real[]).init).writeln;


What does "case [c]:" mean?



In the static foreach c is a `immutable char` by putting it between [ 
and ] you create an array of immutable characters (string).


--
Mike Wey


Re: [your code here] Pure RPN calculator

2017-07-26 Thread Iakh via Digitalmars-d

On Wednesday, 26 July 2017 at 09:46:45 UTC, Timon Gehr wrote:

 readln.split.fold!((stack,op){
 switch(op){
 static foreach(c;"+-*/") case [c]:
 return stack[0..$-2]~mixin("stack[$-2] "~c~" 
stack[$-1]");

 default: return stack~op.to!real;
 }
 })((real[]).init).writeln;


What does "case [c]:" mean?



Re: [your code here] Pure RPN calculator

2017-07-26 Thread Timon Gehr via Digitalmars-d

On 26.07.2017 11:45, Timon Gehr wrote:

On 26.07.2017 04:37, Seb wrote:

On Tuesday, 25 July 2017 at 21:13:54 UTC, Max Haughton wrote:

Semi-Functional/pure RPN calculator: https://run.dlang.io/is/JGkBZx

This is probably too long, but it demonstrates the compiler enforced 
safety and purity (State is passed through the fold), while also 
showing off the higher level parts of Phobos (Use of fold).


Max, this is a great example!
However, as you noticed it's a bit long and in fact in its current 
state it wouldn't look good:


http://imgur.com/a/KwczM

If there's no chance to make it shorter,


import std.stdio, std.string, std.algorithm, std.conv;
void main(){
 readln.split.fold!((stack,op){
 switch(op){
 static foreach(c;"+-*/") case [c]:
 return stack[0..$-2]~mixin("stack[$-2] "~c~" stack[$-1]");
 default: return stack~op.to!real;
 }
 })((real[]).init).writeln;
}



(Sorry for the double post. Internet connection problem.)


Re: [your code here] Pure RPN calculator

2017-07-26 Thread Timon Gehr via Digitalmars-d

On 26.07.2017 04:37, Seb wrote:

On Tuesday, 25 July 2017 at 21:13:54 UTC, Max Haughton wrote:

Semi-Functional/pure RPN calculator: https://run.dlang.io/is/JGkBZx

This is probably too long, but it demonstrates the compiler enforced 
safety and purity (State is passed through the fold), while also 
showing off the higher level parts of Phobos (Use of fold).


Max, this is a great example!
However, as you noticed it's a bit long and in fact in its current state 
it wouldn't look good:


http://imgur.com/a/KwczM

If there's no chance to make it shorter,


import std.stdio, std.string, std.algorithm, std.conv;
void main(){
readln.split.fold!((stack,op){
switch(op){
static foreach(c;"+-*/") case [c]:
return stack[0..$-2]~mixin("stack[$-2] "~c~" stack[$-1]");
default: return stack~op.to!real;
}
})((real[]).init).writeln;
}



Re: [your code here] Pure RPN calculator

2017-07-26 Thread Timon Gehr via Digitalmars-d

On 26.07.2017 04:37, Seb wrote:

On Tuesday, 25 July 2017 at 21:13:54 UTC, Max Haughton wrote:

Semi-Functional/pure RPN calculator: https://run.dlang.io/is/JGkBZx

This is probably too long, but it demonstrates the compiler enforced 
safety and purity (State is passed through the fold), while also 
showing off the higher level parts of Phobos (Use of fold).


Max, this is a great example!
However, as you noticed it's a bit long and in fact in its current state 
it wouldn't look good:


http://imgur.com/a/KwczM

If there's no chance to make it shorter,


import std.stdio,std.string,std.algorithm,std.conv;
void main(){
readln.split.fold!((stack,op){
switch(op){
static foreach(c;"+-*/") case [c]:
return stack[0..$-2]~mixin("stack[$-2] "~c~" stack[$-1]");
default: return stack~op.to!real;
}
})((real[]).init).writeln;
}



Re: [your code here] Pure RPN calculator

2017-07-25 Thread Seb via Digitalmars-d

On Tuesday, 25 July 2017 at 21:13:54 UTC, Max Haughton wrote:
Semi-Functional/pure RPN calculator: 
https://run.dlang.io/is/JGkBZx


This is probably too long, but it demonstrates the compiler 
enforced safety and purity (State is passed through the fold), 
while also showing off the higher level parts of Phobos (Use of 
fold).


Max, this is a great example!
However, as you noticed it's a bit long and in fact in its 
current state it wouldn't look good:


http://imgur.com/a/KwczM

If there's no chance to make it shorter, my suggestion 
considering that there are two other ideas in the queue with a 
similar length problem:


https://github.com/dlang/dlang.org/pull/1759
https://github.com/dlang/dlang.org/pull/1762

would be to find a new home for such "one-page" D example. We 
plan to restructure the DTour (tour.dlang.org) anyways, so how 
about adding a new section like "D in action" to it?


-> I have opened a discussion: 
https://github.com/dlang-tour/english/issues/194


Re: [your code here] Pure RPN calculator

2017-07-25 Thread GrrrrrAngryMan via Digitalmars-d

On Tuesday, 25 July 2017 at 21:13:54 UTC, Max Haughton wrote:
Semi-Functional/pure RPN calculator: 
https://run.dlang.io/is/JGkBZx


This is probably too long, but it demonstrates the compiler 
enforced safety and purity (State is passed through the fold), 
while also showing off the higher level parts of Phobos (Use of 
fold).


Answer to this 
https://forum.dlang.org/post/dhuvztizmqysqsepm...@forum.dlang.org.

This is exactly what the author looked for.


[your code here] Pure RPN calculator

2017-07-25 Thread Max Haughton via Digitalmars-d
Semi-Functional/pure RPN calculator: 
https://run.dlang.io/is/JGkBZx


This is probably too long, but it demonstrates the compiler 
enforced safety and purity (State is passed through the fold), 
while also showing off the higher level parts of Phobos (Use of 
fold).


[your code here]

2017-06-16 Thread jack nivea via Digitalmars-d

To me it seems like the website damplips


[your code here]

2017-06-13 Thread Jorge nqvr via Digitalmars-d

Please send a code



Re: [your code here] bullying

2017-06-09 Thread bethany via Digitalmars-d

On Friday, 9 June 2017 at 18:09:50 UTC, bethany wrote:

hello erin i am sorry you got bullied friend i am hacking


jgsgjb vsnbwhtbknhghtdgh




[your code here] bullying

2017-06-09 Thread bethany via Digitalmars-d

hello erin i am sorry you got bullied friend i am hacking



[your code here]

2017-05-16 Thread hasan via Digitalmars-d

fh


[your code here]

2017-05-04 Thread hdkfjhk via Digitalmars-d

dsfdsfsdfb cxvxcvxcv


Re: [your code here]

2017-03-31 Thread Paul Backus via Digitalmars-d

On Friday, 31 March 2017 at 02:22:14 UTC, April Dale wrote:

I need some informations on what this is


Hovering your mouse over it should cause the following message to 
appear:




Got a brief example illustrating D?

Submit your code to the digitalmars.D forum specifying "[your 
code here]" in

the subject.

Upon approval it will be showcased here on a random schedule.




[your code here]

2017-03-30 Thread April Dale via Digitalmars-d

I need some informations on what this is


[your code here]

2017-03-30 Thread Justin Brown via Digitalmars-d

8
4


[your code here]wikhfdnowijsdoldpaLPML;SADJWSDJJMDA;LMLADMkx;/lkmad;qkes'[qlS]

2017-03-20 Thread via Digitalmars-d
djdjdjbfdlkjsa ncxmjadks,fdmxc nxkjas,md cZXsdknxcl 
medsjakcxjfncx, zmekm, zxcfjdlkx,m czwjkldf xm,zcadf kjadfbjskfn 
jesakfbaksdjfkasjnflkwnsafewckewanrfknesrkanrwaknerdAwknrkwenrkewanrrawkRnDAQwnlsadk.,qwd;lasm,.x


Re: [your code here]

2017-01-13 Thread Ignacious via Digitalmars-d

On Friday, 13 January 2017 at 20:40:32 UTC, mustafa wrote:

dfdsfsd


afdsaaf?


[your code here]

2017-01-13 Thread mustafa via Digitalmars-d

dfdsfsd


Re: [your code here]

2016-12-30 Thread Bauss via Digitalmars-d

On Friday, 30 December 2016 at 08:17:54 UTC, Joseph Agiri wrote:
Why  is the compiler for the D language not downloading from 
your site. It has not enabled me to be entirely fascinated with 
the language with confidence. Please correct the challenge. 
Does it have issues with Windows 7?


The compiler downloads fine for me.

It has no issues with Windows 7.

It's most likely an issue at your end. Could you elaborate more.


[your code here]

2016-12-30 Thread Joseph Agiri via Digitalmars-d
Why  is the compiler for the D language not downloading from your 
site. It has not enabled me to be entirely fascinated with the 
language with confidence. Please correct the challenge. Does it 
have issues with Windows 7?


Re: [your code here]

2016-12-01 Thread Era Scarecrow via Digitalmars-d
On Thursday, 1 December 2016 at 21:37:10 UTC, Sameer Pradhan 
wrote:

On Thursday, 1 December 2016 at 14:26:11 UTC, ringo starr wrote:

swello.edu


This post screams Captcha!
Just to make sure it was not a false positive, I went to the 
(non-existent) URL. On the bright side, the forum seems to be 
widely circulated—enough to attract spammers!


 And for a few moments I thought this was just literally a [post 
your code here] thread which sounds like fun, and I could post 
something useful. I have a chess-knight puzzle solver code I 
could put in... Although maybe if it was more limiting, like code 
under 3k like obfuscation or something.


Re: [your code here]

2016-12-01 Thread Sameer Pradhan via Digitalmars-d

On Thursday, 1 December 2016 at 14:26:11 UTC, ringo starr wrote:

swello.edu


This post screams Captcha!
Just to make sure it was not a false positive, I went to the 
(non-existent) URL. On the bright side, the forum seems to be 
widely circulated—enough to attract spammers!
As far as I can tell, spamming this list is not quite 
straightforward to begin with...


Yay, D!

--
Sameer


[your code here]

2016-12-01 Thread ringo starr via Digitalmars-d

swello.edu


[your code here]

2016-10-11 Thread jessie via Digitalmars-d

judr jpg


Walmond send pictures down up down [your code here]

2016-10-06 Thread Walmond via Digitalmars-d

Send pictures


Re: [your code here]

2016-09-16 Thread c-v-i via Digitalmars-d

On Friday, 16 September 2016 at 08:40:08 UTC, alam wrote:

give me code


void main()
{
foreach(ref const shared shared(immutable(int)) i;
[shared const shared(immutable(int))(0),
shared const shared(immutable(int))(1)]){}
}


Re: [your code here]

2016-09-16 Thread Satoshi via Digitalmars-d

On Friday, 16 September 2016 at 08:40:08 UTC, alam wrote:

give me code




if (2b || !2b) { //to be or not to be? It's funny becasue its true


}


Re: [your code here]

2016-09-16 Thread alam via Digitalmars-d

On Friday, 16 September 2016 at 08:40:08 UTC, alam wrote:

give me code


pou];,wl


[your code here]

2016-09-16 Thread alam via Digitalmars-d

give me code


[your code here]

2016-08-14 Thread Jon via Digitalmars-d

Hi how are you


[your code here]

2016-07-07 Thread fgh via Digitalmars-d

i dont know


[your code here]

2016-01-10 Thread Saurabh Das via Digitalmars-d
The D code part on the front page has only 2 examples currently. 
I thought we should add to that. As per the instructions, I'm 
posting one sample here for approval:


// Find anagrams of words
void main()
{
import std.stdio, std.algorithm;
string[][string] anagram_info;
File("/usr/share/dict/words")
.byLine
.each!(w => anagram_info[w.dup.sort.idup] ~= w.idup);
stdin
.byLine
.map!(l => anagram_info.get(l.sort.idup, []))
.each!writeln;
}


PS: I'm new to writing idiomatic D, so there could be 
improvements to this example. Do point them out :)




Re: [your code here] Rounding real numbers

2015-05-04 Thread Vladimir Panteleev via Digitalmars-d

On Sunday, 3 May 2015 at 04:14:40 UTC, Andrei Alexandrescu wrote:

On 5/2/15 7:48 PM, Vladimir Panteleev wrote:
On Saturday, 2 May 2015 at 22:23:01 UTC, Andrei Alexandrescu 
wrote:

On Friday, 1 May 2015 at 17:17:09 UTC, Justin Whear wrote:

A process for rounding numbers.


Thanks Justin. Could someone take this? We don't have PHP 
code for

rotating examples randomly yet. -- Andrei


Doesn't need to be PHP, just show one example statically and 
switch it

with a random one with JS.


That'd work. I gather you just volunteered :o). -- Andrei


https://github.com/D-Programming-Language/dlang.org/pull/988


Re: [your code here] Rounding real numbers

2015-05-04 Thread Justin Whear via Digitalmars-d
Arrrg, formatting got torn up.  Here's a Dpaste:
http://dpaste.dzfl.pl/ca190950f199


Re: [your code here] Rounding real numbers

2015-05-02 Thread Andrei Alexandrescu via Digitalmars-d

On 5/2/15 7:48 PM, Vladimir Panteleev wrote:

On Saturday, 2 May 2015 at 22:23:01 UTC, Andrei Alexandrescu wrote:

On Friday, 1 May 2015 at 17:17:09 UTC, Justin Whear wrote:

A process for rounding numbers.


Thanks Justin. Could someone take this? We don't have PHP code for
rotating examples randomly yet. -- Andrei


Doesn't need to be PHP, just show one example statically and switch it
with a random one with JS.


That'd work. I gather you just volunteered :o). -- Andrei


Re: [your code here] Rounding real numbers

2015-05-02 Thread Andrei Alexandrescu via Digitalmars-d

On 5/2/15 7:51 PM, Adam D. Ruppe wrote:

On Sunday, 3 May 2015 at 02:48:32 UTC, Vladimir Panteleev wrote:

Doesn't need to be PHP


could also be D


"code or it didn't happen" -- Andrei


Re: [your code here] Rounding real numbers

2015-05-02 Thread Adam D. Ruppe via Digitalmars-d

On Sunday, 3 May 2015 at 02:48:32 UTC, Vladimir Panteleev wrote:

Doesn't need to be PHP


could also be D


Re: [your code here] Rounding real numbers

2015-05-02 Thread Vladimir Panteleev via Digitalmars-d
On Saturday, 2 May 2015 at 22:23:01 UTC, Andrei Alexandrescu 
wrote:

On Friday, 1 May 2015 at 17:17:09 UTC, Justin Whear wrote:

A process for rounding numbers.


Thanks Justin. Could someone take this? We don't have PHP code 
for rotating examples randomly yet. -- Andrei


Doesn't need to be PHP, just show one example statically and 
switch it with a random one with JS.


Re: [your code here] Rounding real numbers

2015-05-02 Thread Andrei Alexandrescu via Digitalmars-d

On Friday, 1 May 2015 at 17:17:09 UTC, Justin Whear wrote:

A process for rounding numbers.


Thanks Justin. Could someone take this? We don't have PHP code 
for rotating examples randomly yet. -- Andrei


[your code here] Rounding real numbers

2015-05-01 Thread Justin Whear via Digitalmars-d
A process for rounding numbers.  This incarnation can be run like
  round 1.23 3.4 4
or by reading lines from stdin.  It could be simplified as an example by 
getting rid of the argument-processing form.  It shows off templated 
function composition using std.functional.pipe, ct-regexes, and component 
programming.
I wrote this after realizing that there wasn't a convenient UNIX utility 
for doing this and use it regularly.

-
import std.algorithm,
std.conv,
std.functional,
std.math,
std.regex,
std.stdio;

// Transforms input into a real number, rounds it, then to a string
alias round = pipe!(to!real, lround, to!string);

// Matches numbers that look like they need rounding
static reFloatingPoint = ctRegex!`[0-9]+\.[0-9]+`;

void main(string[] args)
{
// If arguments, process those and exit, otherwise wait around
//  for input on stdin
if (args.length > 1)
args[1..$].map!round.joiner(" ").writeln;
 
else
// Replace anything that looks like a real number with the 
//  rounded equivalent.
stdin.byLine(KeepTerminator.yes)
 .map!(l => l.replaceAll!(c => c.hit.round)(reFloatingPoint))
 .copy(stdout.lockingTextWriter());
}
-


Re: Dlang.org - your code here

2014-01-03 Thread nazriel
On Thursday, 2 January 2014 at 14:49:50 UTC, Ola Fosheim Grøstad 
wrote:
I like the nice little compiler app on the frontpage, but it 
gets killed most of the time leaving an error. Which is kind of 
unfortunate.


Thank you for reporting this!
Looks like something got borked on dlang.org side.
The same example with same input works OK on dpaste so something 
has to be messed up with communication.


Range between dlang.org and dpaste isn't a problem.

I will look into this, this evening.

Best regards,


Re: Dlang.org - your code here

2014-01-02 Thread Ola Fosheim Grøstad

On Thursday, 2 January 2014 at 19:38:25 UTC, Martin Nowak wrote:

That's actually the backend used on the dlang.org page.


Oh well, maybe it should run on a server closer to the web-host. 
It is kinda discouraging for newbies coming to dlang.org for the 
first time that the demo doesn't respond.


Re: Dlang.org - your code here

2014-01-02 Thread Martin Nowak

On 01/02/2014 03:54 PM, Dejan Lekic wrote:

Try http://dpaste.dzfl.pl/ instead.

That's actually the backend used on the dlang.org page.


Re: Dlang.org - your code here

2014-01-02 Thread Brad Anderson

On Thursday, 2 January 2014 at 14:54:14 UTC, Dejan Lekic wrote:
On Thursday, 2 January 2014 at 14:49:50 UTC, Ola Fosheim 
Grøstad wrote:
I like the nice little compiler app on the frontpage, but it 
gets killed most of the time leaving an error. Which is kind 
of unfortunate.


Try http://dpaste.dzfl.pl/ instead.


I'm pretty sure dlang uses the same system as dpaste so if one is 
down the other probably is too.


Dlang.org - your code here

2014-01-02 Thread Ola Fosheim Grøstad
I like the nice little compiler app on the frontpage, but it gets 
killed most of the time leaving an error. Which is kind of 
unfortunate.


Re: Dlang.org - your code here

2014-01-02 Thread Dejan Lekic
On Thursday, 2 January 2014 at 14:49:50 UTC, Ola Fosheim Grøstad 
wrote:
I like the nice little compiler app on the frontpage, but it 
gets killed most of the time leaving an error. Which is kind of 
unfortunate.


Try http://dpaste.dzfl.pl/ instead.


Re: [your code here]

2013-01-31 Thread Maxim Fomin

On Thursday, 31 January 2013 at 20:43:37 UTC, Ali Çehreli wrote:

On 01/31/2013 10:39 AM, Andrej Mitrovic wrote:
> On 1/31/13, Ali Çehreli  wrote:
>> For the same reason, if it is really an Error that has been
thrown, even
>> the destructors are not called during stack unwinding.
>
> Where are you extracting this information from?

I hope I haven't spread wrong information. I "learned" this 
from the discussions on this forum. Perhaps it was merely an 
idea and I remember it as truth.


Others, is what I said correct? Why do I think that way? :)

Ali


There is not much information about this topic, but I believe 
there are two separate issues here (technical and practical):


1) Errors can behave not always like exceptions. For example, 
most errors (which are not thrown directly) are generated by D 
features: final switch throws SwitchError, notorious activity 
inside class dtors which calls GC causes 
InvalidMemoryOperationError, etc. These are typically called  as 
OnXXError functions and are in druntime 
(https://github.com/D-Programming-Language/druntime/blob/master/src/core/exception.d). 
Theoretically this functions may just terminate application 
without throwing exception, so point here is that even trying to 
catch Error can be useless. However if Error is thrown by D 
exception mechanism, I think you can handle it just like other 
Throwables.


2) Although you can (sometimes) catch Error, state of the program 
is in unpredictable condition. These conditions may depend on 
type of error and other factors.


Re: [your code here]

2013-01-31 Thread Ali Çehreli

On 01/31/2013 12:43 PM, Ali Çehreli wrote:

On 01/31/2013 10:39 AM, Andrej Mitrovic wrote:
 > On 1/31/13, Ali Çehreli wrote:
 >> For the same reason, if it is really an Error that has been thrown,
even
 >> the destructors are not called during stack unwinding.
 >
 > Where are you extracting this information from?

I hope I haven't spread wrong information. I "learned" this from the
discussions on this forum. Perhaps it was merely an idea and I remember
it as truth.

Others, is what I said correct? Why do I think that way? :)


I tested this with dmd. struct destructors do get called during stack 
unwinding.


However, a relevant quote:

  http://dlang.org/phobos/object.html#.Exception

"In principle, only thrown objects derived from [Exception] are safe to 
catch inside a catch block. Thrown objects not derived from Exception 
represent runtime errors that should not be caught, as certain runtime 
guarantees may not hold, making it unsafe to continue program execution."


TDPL talks about what happens (and does not happen) when a function in 
declared as nothrow. It also talks about why Throwable should not be 
caught. It doesn't say the same exact things about Error but the book 
draws a clear distinction between the Exception sub-hierarchy and the 
other exception classes.


There is great information in Chapter 9 of TDPL but they are quite large 
to type here. Especially sections 9.2 and 9.4 are relevant.


The following are my thoughts...

Here is the logic behind why the destructors must not be executed when 
the thrown exception is an Error. AssertError is an Error, indicating 
that the program state is wrong. When the program state is wrong, there 
is no guarantee that any further operation in the program can safely be 
executed.


Assume that the AssertError is coming from the invariant block of a 
struct (or assume that any other assert about the state of an object has 
failed). In that case the object is in a bad state. Can the destructor 
be called on that object? Should it be? What can we expect to happen?


Ali


Re: [your code here]

2013-01-31 Thread Timon Gehr

On 01/31/2013 09:43 PM, Ali Çehreli wrote:

On 01/31/2013 10:39 AM, Andrej Mitrovic wrote:
 > On 1/31/13, Ali Çehreli  wrote:
 >> For the same reason, if it is really an Error that has been thrown,
even
 >> the destructors are not called during stack unwinding.
 >
 > Where are you extracting this information from?

I hope I haven't spread wrong information. I "learned" this from the
discussions on this forum. Perhaps it was merely an idea and I remember
it as truth.

Others, is what I said correct? Why do I think that way? :)

Ali



Destructors are not "guaranteed" to run. They actually do. I think this 
is mostly to allow segmentation faults on Linux.


Re: [your code here]

2013-01-31 Thread Ali Çehreli

On 01/31/2013 10:39 AM, Andrej Mitrovic wrote:
> On 1/31/13, Ali Çehreli  wrote:
>> For the same reason, if it is really an Error that has been thrown, even
>> the destructors are not called during stack unwinding.
>
> Where are you extracting this information from?

I hope I haven't spread wrong information. I "learned" this from the 
discussions on this forum. Perhaps it was merely an idea and I remember 
it as truth.


Others, is what I said correct? Why do I think that way? :)

Ali



Re: [your code here]

2013-01-31 Thread Ali Çehreli

On 01/31/2013 12:42 AM, Roumen Roupski wrote:

> catch (Throwable ex)
> {
> writefln("File read error: %s", ex.msg);
> return false; // cannot compare the files

Throwable is a little too high in the exception hierarchy:

Throwable
/  \
ErrorException
 /  \  /   \

A program should catch only Exception and its subtypes. The Error 
sub-hierarchy represents errors about the state of the program. The 
program state may be so invalid that it is not guaranteed that even 
writefln() or 'return' will work.


For the same reason, if it is really an Error that has been thrown, even 
the destructors are not called during stack unwinding.


Ali



Re: [your code here]

2013-01-31 Thread FG

On 2013-01-31 15:17, bearophile wrote:

FG:


Strange. No problems here. Only had to switch from dmd32 to gdc64 with 1GB or
bigger files. Tested on win7-64.


How much memory is it using? What's the performance compared to the diff tool?


Two identical files, 1069 MB each. Program compiled with GDC, 64-bit.
Used 6272 kB private mem / 2144 MB working set, and took 13.5 seconds.
Cygwin's diff took only 1.85 s.



Re: [your code here]

2013-01-31 Thread bearophile

FG:

Strange. No problems here. Only had to switch from dmd32 to 
gdc64 with 1GB or bigger files. Tested on win7-64.


How much memory is it using? What's the performance compared to 
the diff tool?


Bye,
bearophile


Re: [your code here]

2013-01-31 Thread FG

On 2013-01-31 14:21, bearophile wrote:

Especially when you are comparing 500 MB files in a loop. :)


I have had problems comparing with this program a single pair of files that
large...


Strange. No problems here. Only had to switch from dmd32 to gdc64 with 1GB or 
bigger files. Tested on win7-64.




Re: [your code here]

2013-01-31 Thread Vladimir Panteleev

On Thursday, 31 January 2013 at 12:28:43 UTC, FG wrote:

On 2013-01-31 12:38, Namespace wrote:

If you want to do something, then take destroy.
AFAIK delete destroy _and_ release the memory immediately. 
'destroy' doesn't.


And that's why delete is valuable (at least on 32-bit windows).
Especially when you are comparing 500 MB files in a loop. :)


If we are talking about memory mapped files, then destroying the 
MmFile classes will close the mappings, thus freeing the virtual 
memory.


Anyway, I'm really impressed by this example, as the kernel may 
be inclined to leave the pages we've already compared in RAM 
(might be fixed with madvise(MADV_SEQUENTIAL)), and it doesn't 
demonstrate many D strengths (memory-mapped files are an OS 
feature, for which D just provides a wrapper class). Maybe it 
would be more interesting if we use std.algorithm.zip or 
.lockstep or .equal with File.byChunk?


Re: [your code here]

2013-01-31 Thread bearophile

FG:


Especially when you are comparing 500 MB files in a loop. :)


I have had problems comparing with this program a single pair of 
files that large...


Bye,
bearophile


Re: [your code here]

2013-01-31 Thread Namespace

On Thursday, 31 January 2013 at 12:28:43 UTC, FG wrote:

On 2013-01-31 12:38, Namespace wrote:

If you want to do something, then take destroy.
AFAIK delete destroy _and_ release the memory immediately. 
'destroy' doesn't.


And that's why delete is valuable (at least on 32-bit windows).
Especially when you are comparing 500 MB files in a loop. :)


I like and use it also. ;)


Run GC.collect() After destroy.


collect? Maybe free, but collect seems a bit like to take a 
sledgehammer to crack a nut.


Re: [your code here]

2013-01-31 Thread simendsjo

On Thursday, 31 January 2013 at 12:28:43 UTC, FG wrote:

On 2013-01-31 12:38, Namespace wrote:

If you want to do something, then take destroy.
AFAIK delete destroy _and_ release the memory immediately. 
'destroy' doesn't.


And that's why delete is valuable (at least on 32-bit windows).
Especially when you are comparing 500 MB files in a loop. :)


Run GC.collect() After destroy.


  1   2   >