On Sunday, 21 August 2016 at 23:57:27 UTC, brian wrote:
On Sunday, 21 August 2016 at 23:37:38 UTC, Adam D. Ruppe wrote:
testStruct[int] testStructArray;
That's not actually an array per se, that is a key/value map
where the keys are ints.
I understand it's a map, but does my syntax not define
On Sunday, 21 August 2016 at 19:30:51 UTC, Guillaume Piolat wrote:
5) Is there a way to do simple heap allocation with 'new'
while ensuring the GC doesn't deallocate until I want it to?
Keep a reference somewhere reachable (by default: stack, heap,
globals: everything is reachable and scanned
On 22/08/2016 5:22 PM, Sai wrote:
Thanks all for your replies.
I tried to use GDC first, I couldn't find windows binary targeting
windows (for initial testing) which I thought was weird.
https://gdcproject.org/downloads
So I tried to build it in Cygwin env, using these instructions:
http://wiki
Thanks all for your replies.
I tried to use GDC first, I couldn't find windows binary
targeting windows (for initial testing) which I thought was
weird. https://gdcproject.org/downloads
So I tried to build it in Cygwin env, using these instructions:
http://wiki.dlang.org/GDC/Installation/Gene
On Monday, 22 August 2016 at 04:52:40 UTC, Cauterite wrote:
On Monday, 22 August 2016 at 04:37:50 UTC, stunaep wrote:
I made a union to convert between int bits and floats, but the
values are coming out wrong sometimes.
I can already tell what this is going to be...
The problem is almost certa
On Monday, 22 August 2016 at 04:37:50 UTC, stunaep wrote:
I made a union to convert between int bits and floats, but the
values are coming out wrong sometimes.
I can already tell what this is going to be...
The problem is almost certainly nothing to do with your union,
it's this line:
float t
On Monday, 22 August 2016 at 04:37:50 UTC, stunaep wrote:
I made a union to convert between int bits and floats, but the
values are coming out wrong sometimes. This is working without
issue in other languages so I'm really stumped. Here's an
example:
union test { int i; float f; }
test t = {
I made a union to convert between int bits and floats, but the
values are coming out wrong sometimes. This is working without
issue in other languages so I'm really stumped. Here's an example:
union test { int i; float f; }
test t = { i : 0x7fb0};
float t2 = t.f;//int bits 0x7fb0 as fl
On Monday, 22 August 2016 at 01:45:02 UTC, Jonathan M Davis wrote:
On Monday, August 22, 2016 00:14:31 Adam D. Ruppe via
Digitalmars-d-learn wrote:
int strncmp(string a, string b, int n) {
if(a.length > n)
a = a[0 .. n];
if(b.length > n)
b = b[0 .. n];
import std.algorithm.comp
On Sunday, 10 January 2016 at 17:50:44 UTC, Vlad Leberstein wrote:
As I'm not very good at D, I would like to get some feedback
about this solutions' viability. AFAIU memcpy-ing struct here
is safe because all target arguments ever passed to tryPutting
are internal to implementation(and SHOUL
On Monday, August 22, 2016 00:14:31 Adam D. Ruppe via Digitalmars-d-learn
wrote:
> int strncmp(string a, string b, int n) {
> if(a.length > n)
> a = a[0 .. n];
> if(b.length > n)
> b = b[0 .. n];
> import std.algorithm.comparison : cmp;
> return cmp(a, b);
> }
Aside from the i
On Monday, 22 August 2016 at 00:22:48 UTC, ag0aep6g wrote:
On 08/22/2016 12:06 AM, Engine Machine wrote:
T!()'s "data" is specified in the class just like all the other
derivations. I don't want to have to specify an external base
class as
in your InstaniateOrBase. Why? Because!!! (There should
On 08/22/2016 12:06 AM, Engine Machine wrote:
T!()'s "data" is specified in the class just like all the other
derivations. I don't want to have to specify an external base class as
in your InstaniateOrBase. Why? Because!!! (There should be no need to,
and if one goes this route of creating classe
int strncmp(string a, string b, int n) {
if(a.length > n)
a = a[0 .. n];
if(b.length > n)
b = b[0 .. n];
import std.algorithm.comparison : cmp;
return cmp(a, b);
}
On Sunday, 21 August 2016 at 23:57:27 UTC, brian wrote:
I understand it's a map, but does my syntax not define an
Associative Array??
yeah, it is. If that's what you want, good!
So I wanted something dynamic.
OK, then you should use pointers so you can have several
references to the same o
In c, there's this very nice function strncmp(s1,s2,count) which
compares two c strings, using at most count characters. count
can be less than, more than, or equal to either or both of the
lengths of the two strings. It can be used to see if two
c-strings have the same prefix of some length.
Thanks Adam.
Couple of follow up questions, if you don't mind:
On Sunday, 21 August 2016 at 23:37:38 UTC, Adam D. Ruppe wrote:
testStruct[int] testStructArray;
That's not actually an array per se, that is a key/value map
where the keys are ints.
I understand it's a map, but does my syntax not
On Sunday, 21 August 2016 at 23:28:14 UTC, brian wrote:
/* creates(?) an empty array of structs */
testStruct[int] testStructArray;
That's not actually an array per se, that is a key/value map
where the keys are ints.
So you can set values to it at any position in it but not append
or do ot
So I have the below program:
import std.stdio;
/* defines my awesome struct */
struct testStruct
{
string aa;
string bb;
}
/* creates(?) an empty array of structs */
testStruct[int] testStructArray;
void main()
{
string a = "a";
string b = "b";
/*make a
On Sunday, 21 August 2016 at 21:11:37 UTC, ag0aep6g wrote:
On 08/21/2016 09:29 PM, Engine Machine wrote:
I know you like to play the right or wrong game, but did you
ever learn
that a single example does not prove the truth of something?
But you can show in a single example that something doe
On 08/21/2016 10:06 PM, cy wrote:
in the module scope, you start with:
auto pattern = ctRegex!"foobar";
and you substitute with:
typeof(regex("")) pattern;
static this() {
pattern = regex("foobar");
}
I may be missing the point here, but just putting `auto pattern =
regex("foobar");` at mod
On 08/21/2016 09:29 PM, Engine Machine wrote:
I know you like to play the right or wrong game, but did you ever learn
that a single example does not prove the truth of something?
But you can show in a single example that something doesn't work. You
tried to do that, and you did it with a simpl
On Sunday, 21 August 2016 at 20:36:54 UTC, Engine Machine wrote:
On Sunday, 21 August 2016 at 19:42:08 UTC, Lodovico Giaretta
wrote:
[...]
You're right. I didn't realize that variables could be shadowed
in classes. Seems dangerous. D doesn't allow shadowing in a
normal context and gives an e
On Sunday, 21 August 2016 at 19:42:08 UTC, Lodovico Giaretta
wrote:
On Sunday, 21 August 2016 at 19:29:26 UTC, Engine Machine wrote:
[...]
The problem of this code has nothing to do with aliases. They
work correctly. The problem is variable shadowing. In the
following code, Child has two x v
On Sunday, 21 August 2016 at 19:29:26 UTC, Engine Machine wrote:
I know you like to play the right or wrong game, but did you
ever learn that a single example does not prove the truth of
something?
How about something more complex?
Your demagogy will not help you learn the basics of the D
lan
On Wednesday, 17 August 2016 at 19:38:22 UTC, Engine Machine
wrote:
Well, the is does work and that probably is the best solution.
I don't mind the extra type at this point. Of course, a library
solution for this type of stuff would be nice. I'd rather not
have to even use a type but rather use
On Saturday, 20 August 2016 at 22:18:57 UTC, Engine Machine wrote:
On Saturday, 20 August 2016 at 22:11:40 UTC, Engine Machine
wrote:
Is there a way to rebind the arguments of a template?
template foo(X)
{
// X is like A!(a,b,c)
Y = Rebind!(X,d,e,f);
// Y is like A!(d,e,f);
}
foo(A!(a
At seconds PER (character range) pattern, ctRegex slows down
compilation like crazy, but it's not obvious how to avoid using
it, since Regex(Char) is kind of weird for a type. So, here's
what I do. I think this is right.
in the module scope, you start with:
auto pattern = ctRegex!"foobar";
an
Thanks to both of you. I think that answers everything, except if
new'd objects can be freed when GC is disabled. I guess I could
always enable and call collect().
On Sunday, 21 August 2016 at 19:42:08 UTC, Lodovico Giaretta
wrote:
On Sunday, 21 August 2016 at 19:29:26 UTC, Engine Machine wrote:
[...]
The problem of this code has nothing to do with aliases. They
work correctly. The problem is variable shadowing. In the
following code, Child has two x v
On Sunday, 21 August 2016 at 19:29:26 UTC, Engine Machine wrote:
[...]
The problem of this code has nothing to do with aliases. They
work correctly. The problem is variable shadowing. In the
following code, Child has two x variables, one of which is only
accessible from a Parent reference, t
On Sunday, 21 August 2016 at 16:14:53 UTC, Zane wrote:
Hey all,
My knowledge of GCs is limited, but my faith in them (for most
applications) has greatly increased with advances (like with
Golang's recent updates). I am now trying to get a better sense
for the direction D is going regarding me
On Sunday, 21 August 2016 at 06:28:25 UTC, Jack Applegame wrote:
On Sunday, 21 August 2016 at 00:06:07 UTC, Engine Machine wrote:
On Saturday, 20 August 2016 at 22:21:00 UTC, ag0aep6g wrote:
On 08/21/2016 12:11 AM, Engine Machine wrote:
Is there a way to rebind the arguments of a template?
te
On Sunday, 21 August 2016 at 18:31:26 UTC, Zane wrote:
I see - That makes sense, but is there no way to "pause/stop"
the GC, but still be able to use the 'new' syntax?
Oh you can use `new` when the GC is disabled, no problem. All the
GC's functionality is still available.
But be careful abou
On Sunday, 21 August 2016 at 16:38:09 UTC, Cauterite wrote:
On Sunday, 21 August 2016 at 16:14:53 UTC, Zane wrote:
5) Is there a way to do simple heap allocation with 'new'
while ensuring the GC doesn't deallocate until I want it to?
I can answer this at least,
If you don't want the GC to ever
On Sunday, 21 August 2016 at 16:14:53 UTC, Zane wrote:
1) If using the GC, but for whatever reason, I need to free
something _right now_, is core.GC.free() the proper way to do
this?
The main problem is that `new` does not necessarily give you a
pointer to the start of an allocation, and `GC.
On Wednesday, 4 December 2013 at 23:23:51 UTC, Rob T wrote:
On Wednesday, 4 December 2013 at 08:38:12 UTC, qznc wrote:
You should file an issue [0] as this should actually be in
core.thread.
[0] https://d.puremagic.com/issues/enter_bug.cgi
I filed an enhancement request for the thread modu
On Sunday, 21 August 2016 at 16:14:53 UTC, Zane wrote:
5) Is there a way to do simple heap allocation with 'new' while
ensuring the GC doesn't deallocate until I want it to?
While my earlier suggestion of using malloc/emplace is one
option, another is to use `GC.addRoot(objPtr)`. It ensures th
On Sunday, 21 August 2016 at 16:14:53 UTC, Zane wrote:
2) Does calling object.destroy() mean that the object is marked
for future collection? If not, how can I ensure it is properly
marked.
Because the GC is not of the incremental type, it can't perform
any marking outside of a stop-the-world
On Sunday, 21 August 2016 at 16:14:53 UTC, Zane wrote:
6) If the GC is off, how is allocation/deallocation handled?
Can I still use new for example (and how do I dealloc)?
All the allocation/deallocation functionality is the same as
normal, except the GC won't start a collection cycle unless i
On Sunday, 21 August 2016 at 16:14:53 UTC, Zane wrote:
5) Is there a way to do simple heap allocation with 'new' while
ensuring the GC doesn't deallocate until I want it to?
I can answer this at least,
If you don't want the GC to ever collect the object itself,
here's the best way:
Allocate th
Hey all,
My knowledge of GCs is limited, but my faith in them (for most
applications) has greatly increased with advances (like with
Golang's recent updates). I am now trying to get a better sense
for the direction D is going regarding memory management, both in
relation to the GC and without
On Sunday, 21 August 2016 at 15:25:59 UTC, David Nadlinger wrote:
On Sunday, 21 August 2016 at 14:57:15 UTC, Seb wrote:
An alternative would be to compile your application locally,
then copy it over to your container. I don't know how similar
CoreOs to a typical Linux distribution is, but if it
On Sunday, 21 August 2016 at 14:57:15 UTC, Seb wrote:
An alternative would be to compile your application locally,
then copy it over to your container. I don't know how similar
CoreOs to a typical Linux distribution is, but if it comes with
the typical shared libraries (libm.so, libc.so, lipthr
On Sunday, 21 August 2016 at 11:38:09 UTC, Suliman wrote:
I would like to create small VPS instance with Linux distrib on
VPS. Can I use CoreOS as image? Would it possible to install
dlang there?
An alternative would be to compile your application locally, then
copy it over to your container.
On Sunday, 21 August 2016 at 11:38:09 UTC, Suliman wrote:
I would like to create small VPS instance with Linux distrib on
VPS. Can I use CoreOS as image? Would it possible to install
dlang there?
For LDC, you can just download the latest release from
https://github.com/ldc-developers/ldc/rele
I would like to create small VPS instance with Linux distrib on
VPS. Can I use CoreOS as image? Would it possible to install
dlang there?
47 matches
Mail list logo