Hi!
Why in std.file toStringz used without store a pointer in
function body to prevent GC collection?
https://github.com/D-Programming-Language/phobos/blob/master/std/file.d
Best Regards,
Ilya
On Wednesday, 29 January 2014 at 08:27:14 UTC, Ilya Yaroshenko
wrote:
Hi!
Why in std.file toStringz used without store a pointer in
function body to prevent GC collection?
https://github.com/D-Programming-Language/phobos/blob/master/std/file.d
Best Regards,
Ilya
It is assumed that the
On 1/29/14, Jakob Ovrum jakobov...@gmail.com wrote:
On a related note, I would like the body of a template to be able
to access aliases introduced in IsExpression's in the template's
constraints.
Me too, but I can't remember if this was filed in bugzilla.
On Wednesday, 29 January 2014 at 07:20:52 UTC, Uranuz wrote:
I continue to practice with web applications on D and I have
some questions about secure protocols of data transmissions. I
don't have any experience with SSL/TLS so I need an advice how
to get started. Is there any ready solution
In this case I want client programme on D that will communicate
with some server over secure HTTP. I want to be able to update
DNS records via it's web API using web interface of my web
application written on D. I could do it using some cross-site
request on JavaScript XmlHTTPRequest, but I want
Hello everybody. I'm trying to learn D by solving simple
exercises.
The current exercise: read names and grades of students, then
print the names of students in descending order of their grades.
In C++, I would define a Student struct, overload the operators:
bool operator(const Student, const
It's also worth noting that you can avoid passing structs into
predicate function by value, and instead pass them by reference:
sort!((ref const a, ref const b) = a.grade b.grade)(students);
This is useful for heavy structs to save on performance. E.g.
in this case, Student.sizeof is 24 bytes
On Wednesday, 29 January 2014 at 00:28:29 UTC, Meta wrote:
You can also use the Github Gist feature for displaying code,
can't you?
But you'd need a github account for that, won't you? :)
Also sorry for double posting but I'm confused how the sorting
works when we only specify to be sorted by grade. I think in C++,
disregarding other data members can lead to loss of data in
things such as std::set.
Thanks for the help so far.
My current code is here: http://dpaste.dzfl.pl/b9acff399649
Are there problems with my code, or do you have suggestions to
improve it?
One can always turn global into pointer to immutable - it will
preserve most benefits but can be always replaced with
differently initialized one.
On Wednesday, 29 January 2014 at 10:30:06 UTC, Boomerang wrote:
I'll paste here with comments:
import std.algorithm;
import std.stdio;
import std.array;
void main()
{
struct Student
{
string name;
float grade;
}
Student[] studs;
writeln(Enter student data.
On Wednesday, 29 January 2014 at 10:55:57 UTC, Cooler wrote:
Consider 3 functions taking array as an argument:
void fun1(in int[] x){...}
void fun2(ref int[] x){...}
void fun3(int[] x){...}
auto a = new int[10];
fun1(a); // Guaranteed that a will not be changed
fun2(a); // Guaranteed
On Wednesday, 29 January 2014 at 11:46:23 UTC, Cooler wrote:
Thank you for detailed explanation. But the question is - Is
that correct that language allows ambiguous behavior?
Could you expand your example?
fun(int[] a) {} is passing a by value, that is, the pointer and
length is copied over
On Wednesday, 29 January 2014 at 11:46:23 UTC, Cooler wrote:
Thank you for detailed explanation. But the question is - Is
that correct that language allows ambiguous behavior?
Where is it ambiguous?
On Wednesday, 29 January 2014 at 12:44:37 UTC, Tobias Pankrath
wrote:
On Wednesday, 29 January 2014 at 11:24:54 UTC, Stanislav Blinov
wrote:
// Or avoid foreach altogether:
studs.map!((ref const s) = writeln(s.name));
}
Did you test this one? std.algorithm.map is lazy.
Ah yes, sorry,
On Wednesday, 29 January 2014 at 13:15:30 UTC, Cooler wrote:
On Wednesday, 29 January 2014 at 12:40:00 UTC, Tobias Pankrath
wrote:
On Wednesday, 29 January 2014 at 11:46:23 UTC, Cooler wrote:
Thank you for detailed explanation. But the question is - Is
that correct that language allows
On Wednesday, 29 January 2014 at 08:29:42 UTC, Jakob Ovrum wrote:
On Wednesday, 29 January 2014 at 08:27:14 UTC, Ilya Yaroshenko
wrote:
Hi!
Why in std.file toStringz used without store a pointer in
function body to prevent GC collection?
On Wednesday, 29 January 2014 at 13:15:30 UTC, Cooler wrote:
On Wednesday, 29 January 2014 at 12:40:00 UTC, Tobias Pankrath
wrote:
On Wednesday, 29 January 2014 at 11:46:23 UTC, Cooler wrote:
Thank you for detailed explanation. But the question is - Is
that correct that language allows
On 01/29/2014 02:55 AM, Cooler wrote:
Consider 3 functions taking array as an argument:
void fun1(in int[] x){...}
void fun2(ref int[] x){...}
void fun3(int[] x){...}
auto a = new int[10];
fun1(a); // Guaranteed that a will not be changed
fun2(a); // Guaranteed that we will see any
Jakob Ovrum:
We can already do this, but you have to omit the `Unused` alias
(a semi-recent enhancement allows for that):
---
import std.traits : Unqual;
struct Tuple(Args...) {}
enum isTuple(T) = is(Unqual!T : Tuple!Types, Types...);
Thank you.
Bye,
bearophile
You can also use OpenSSL. I wrote a little wrapper class that
extends std.socket.Socket for it:
https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff/blob/master/sslsocket.d
If you download that file and compile it with your app:
dmd yourfile.d sslsocket.d
you
On Wednesday, 29 January 2014 at 15:11:33 UTC, Cooler wrote:
Yes, that is how slices work in D. The following article
explains the non-determinism that you mention:
http://dlang.org/d-array-article.html
Ali
Thank you for the article.
Quotation from the article It is a good idea to note in
On Wednesday, 29 January 2014 at 15:11:33 UTC, Cooler wrote:
Yes, that is how slices work in D. The following article
explains the non-determinism that you mention:
http://dlang.org/d-array-article.html
Ali
Thank you for the article.
Quotation from the article It is a good idea to note in
On Wednesday, 29 January 2014 at 15:38:34 UTC, Cooler wrote:
It's not unpredictable, at least not more unpredictable then
fun2.
Should we dissallow this two?
int[] a = [1,2,3,4];
b = a;
b ~= [5, 6, 7, 8];
You don't understand me. You consider that I am author of the
fun() and the caller
On Wednesday, 29 January 2014 at 16:01:08 UTC, Cooler wrote:
Do you read my post? I am answering... why do I need fun3() if
I already have fun1() and fun2().
fun3 guarantees that the argument has the same length for example.
On Wednesday, 29 January 2014 at 16:26:05 UTC, Cooler wrote:
Where argument has the same length? After function call, or
inside function? I don't understand what my intention should be
to push me to use fun3()?
Gosh. To allow the function to modify the contents, but not the
size of the
On Friday, 24 January 2014 at 15:56:26 UTC, bearophile wrote:
If someone if willing to test LDC2 with a known benchmark,
there's this one:
http://benchmarksgame.alioth.debian.org/u32/performance.php?test=nbody
A reformatted C++11 version good as start point for a D
translation:
Stanislav Blinov:
Hmm.. How would one use core.simd with LDC2? It doesn't seem to
define D_SIMD.
Or should I go for builtins?
I don't know if this is useful for you, but here I wrote a basic
usage example of SIMD in ldc2 (second D entry):
http://rosettacode.org/wiki/Four_bits_adder#D
Bye,
Meta:
auto tags = tags.flatMap!uniq.array ?
That's another solution. In Phobos a flatMap can be useful (just
as a zip overload that accepts a function to apply on the pairs,
named zipWith in haskell:
http://zvon.org/other/haskell/Outputprelude/zipWith_f.html ).
Bye,
bearophile
On Wednesday, 29 January 2014 at 16:43:35 UTC, bearophile wrote:
Stanislav Blinov:
Hmm.. How would one use core.simd with LDC2? It doesn't seem
to define D_SIMD.
Or should I go for builtins?
I don't know if this is useful for you, but here I wrote a
basic usage example of SIMD in ldc2
Stanislav Blinov:
I meant how to make it compile with ldc2? I've translated the
code, it compiles and works with dmd (although segfaults in
-release mode for some reason, probably a bug somewhere).
But with ldc2:
nbody.d(68): Error: undefined identifier __simd
nbody.d(68): Error: undefined
On Wednesday, 29 January 2014 at 16:54:27 UTC, Cooler wrote:
On Wednesday, 29 January 2014 at 16:36:44 UTC, Stanislav Blinov
wrote:
On Wednesday, 29 January 2014 at 16:26:05 UTC, Cooler wrote:
Where argument has the same length? After function call, or
inside function? I don't understand what
On Wednesday, 29 January 2014 at 17:11:32 UTC, Ary Borenszweig
wrote:
Yes, as there are other ways for body: _body, _body, Body,
HtmlBody, etc. But body is the best one.
torso? ;)
On 1/28/14, 3:17 PM, Chris wrote:
On Tuesday, 28 January 2014 at 17:18:44 UTC, Ary Borenszweig wrote:
On 1/28/14, 11:30 AM, bearophile wrote:
Ary Borenszweig:
In Ruby you can do this:
class Foo
def end
1
end
end
Foo.new.end
Ruby is a different language from D, they define code
On Wednesday, 29 January 2014 at 16:54:54 UTC, bearophile wrote:
Stanislav Blinov:
I meant how to make it compile with ldc2? I've translated the
code, it compiles and works with dmd (although segfaults in
-release mode for some reason, probably a bug somewhere).
But with ldc2:
nbody.d(68):
On Wednesday, 22 January 2014 at 11:58:17 UTC, Rikki Cattermole
wrote:
On Wednesday, 22 January 2014 at 11:14:22 UTC, ilya-stromberg
wrote:
Do you know any library with OAuth support?
Not currently.
But I can add it to my todo list for Cmsed[0].
[0] https://github.com/rikkimax/Cmsed
Yes,
import std.stdio;
import core.vararg;
auto veryStableAPI(bool brave = false)(string parameter, ...)
{
static if (!brave)
{
pragma(msg, I'm not brave);
}
else
{
pragma(msg, I'm very brave);
}
}
void main(string[]
valid according to spec ?
Only trailing parameter can have default arguments.
(Guess is didn't get sent, I guess I'm just a big spam bot cause
I keep getting flagged every post)
The following code demonstrates a way to have an easy factory in
D requiring very little work. I imagine it can be improved to
handle the abstract case(basically dependencies/constraints).
Any
You need to fill in the cbSize field like so:
wce.cbSize = WNDCLASSEXA.sizeof;
Ungh. How embarassing. Now it works, thank you.
On Wednesday, 29 January 2014 at 18:24:22 UTC, Uplink_Coder wrote:
is it legal or is it not ?
Yours isn't, no.
Hey, I'm handling concurrency with message passing, previously
with D's concurrency, now with Vibe-d, which I assume works the
same way.
My app is a chat server, and when a connection is opened to a
client, I store the Tid of the thread (or fibre?) handling
sending messages out to the
A small example:
while (true) {
receive(
(Tid tid, AddTid _) {some code}
(Tid tid, RemoveTid _) {some other code}
(string s) {broadcast stuff}
)
}
struct AddTid {}
struct RemoveTid {}
On Wednesday, 29 January 2014 at 21:50:28 UTC, Casper Færgemand
wrote:
A small example:
while (true) {
receive(
(Tid tid, AddTid _) {some code}
(Tid tid, RemoveTid _) {some other code}
(string s) {broadcast stuff}
)
}
struct AddTid {}
struct RemoveTid {}
From where I sit
Le 22/01/2014 14:13, Flamaros a écrit :
On Wednesday, 22 January 2014 at 02:11:02 UTC, TheFlyingFiddle wrote:
On Saturday, 18 January 2014 at 19:40:38 UTC, Xavier Bigand wrote:
I am not sure the issue come really from my code, cause it just works
fine on ATI cards, I do something Nvidia
On Wednesday, 29 January 2014 at 11:24:54 UTC, Stanislav Blinov
wrote:
On Wednesday, 29 January 2014 at 10:30:06 UTC, Boomerang wrote:
// also it's worth using ref const to avoid
// unnecessary copies
I am new to D.
Why should someone use ref const instead of in?
So, there is a module core.stdc.config (referenced here):
http://dlang.org/interfaceToC.html
That is presumably part of the D Standard library. I am curious
to know why no mention of this library is included at:
http://dlang.org/phobos/index.html
Is it not part of Phobos? Are there
On Friday, 21 January 2011 at 20:50:39 UTC, Jonathan M Davis
wrote:
On Friday, January 21, 2011 12:36:23 Ary Manzana wrote:
On 1/20/11 5:48 PM, Jacob Carlborg wrote:
On 2011-01-20 21:34, Steven Schveighoffer wrote:
On Thu, 20 Jan 2011 15:03:55 -0500, Jacob Carlborg
d...@me.com wrote:
On
On Thursday, 30 January 2014 at 03:00:43 UTC, Paul-Andre wrote:
On Wednesday, 29 January 2014 at 11:24:54 UTC, Stanislav Blinov
wrote:
On Wednesday, 29 January 2014 at 10:30:06 UTC, Boomerang wrote:
// also it's worth using ref const to avoid
// unnecessary copies
I am new to D.
Why
On 1/30/2014 12:28 PM, Craig Dillabaugh wrote:
Is it not part of Phobos? Are there standard modules in D that are not
included in Phobos? If so, where would one find the list of these modules.
All of the core.* modules are part of DRuntime, not Phobos.
On Wednesday, 29 January 2014 at 16:26:05 UTC, Cooler wrote:
On Wednesday, 29 January 2014 at 16:15:36 UTC, Tobias Pankrath
wrote:
On Wednesday, 29 January 2014 at 16:01:08 UTC, Cooler wrote:
Do you read my post? I am answering... why do I need fun3()
if I already have fun1() and fun2().
On 2014-01-30 05:42, Mike Parker wrote:
All of the core.* modules are part of DRuntime, not Phobos.
Unfortunately none of the core.stdc.* modules are documented. It's
understandable that duplicating the documentation of the C library is
not done since that would require extra work. But it
53 matches
Mail list logo