pecting an full struct.
Adding __gshared doesn't help.
I assume this is bug, since usage of extern means that I don't
need to know the size, since it will be allocated in the C code,
not the D code.
--
James Miller
* James Miller [2012-04-13 19:16:48 +1200]:
> * Paul D. Anderson
> [2012-04-13 07:50:31 +0200]:
> > I'm trying to add formatted output to my decimal arithmetic module.
> > Decimals should format like floating point, using 'E', 'F' and 'G',
l
>
>
Hey Paul, so some investigation has led me to believe that FormatSpec is
really just for internal usage. The documentation is a bit misleading
(to the point of being possibly completely false).
FormatSpec, AFAICT, is essentially just a parser for the standard format
specifier, but its not very clear as to proper usage. I'm going to try
to improve it and submit a pull request, until then looking at the
source code for std.format should give you some idea of how to best use
it.
--
James Miller
uniform!("[]")(a,b);
You can also do "()" and "(]" to obtain the other two intervals
--
James Miller
* James Miller [2012-04-13 02:49:03 +1200]:
> Glad you got help Xan, but for future reference can you please keep
> questions to D.learn? It is somewhat frustrating to see the question
> "How do I do that?" on this list, since it is for discussion, and
> high-level question
quot;How do I do that?" on this list, since it is for discussion, and
high-level questions, not for people that are learning D.
(High level questions being along the lines of "What changes need to be
made in dmd to support the new AA implementation?")
--
James Miller
) seem to handle
replying well, setting the correct headers to indicate things. But I've
seen some odd postings from people posting using things like Windows
Live Mail. And it seems that Outlook Express is better at mailing lists
than Outlook, which is strange...
--
James Miller
as I'm aware) the
compiler emits a template instantiation of opBinary("/") for the type. That
means that you can add on more template arguments.
3. Using `auto` means that the compiler works out the type, so you don't have
to add extra template arguments to calculate the correct type.
Hope that helps.
--
James Miller
On 4 April 2012 10:32, jicman wrote:
> How can I make args global?
>
> thanks,
In D, technically the only way is to use Runtime, as Andrej mentioned.
As an aside, it is worth noting there is no global scope in D, module
is as high as you go.
?)?
- Would it be possible to use custom allocators to write a completely
GC-free application (using ref-counting instead for example)? Or would
the GC still be used anyway?
If I'm way off base on anything, feel free to say so, memory
management and garbage collection aren't exactly my strong suits.
Thanks
--
James Miller
of your situation, you could also use
conditional compilation in conjunction with templates to implement
your policies, often interfaces aren't needed when you only want/need
a minor change, I only use them for polymorphism in D.
--
James Miller
se
> it works fine for arrays but apperantly not for lists.
>
> How do I add an element to a list?
opAppend (or whatever it is) isn't defined for alot of types that it
probably should be. There should be an append method that you can use
though.
--
James Miller
On 31 March 2012 06:28, Jonathan M Davis wrote:
> it also has
> opDot, which is being removed from the language.
Out of curiosity, what was opDot?
--
James Miller
ons, not templates,
or rather its Uniform Function-Call Syntax, not Uniform
Template-Instantiation Syntax (UTIS?). Because even ext(T)(); is just
sugar for:
template ext(T) {
void ext();
}
--
James Miller
On 29 March 2012 17:05, Jesse Phillips wrote:
> On Thursday, 29 March 2012 at 03:40:55 UTC, James Miller wrote:
>
>> I award thee the "Necromancer" badge, for reviving a long-dead thread.
>>
>> --
>> James Miller
>
>
> I find the distaste of rev
e like I did):
I award thee the "Necromancer" badge, for reviving a long-dead thread.
--
James Miller
On 28 March 2012 19:35, Andrej Mitrovic wrote:
> I'd like to get a list of indexes into an array that matches a character.
> E.g.:
>
> "a foo a bar a".indexes("a") == [0, 6, 12]
>
> Anything like that in Phobos?
std.regex might be able to produce something like it.
--
James Miller
s an odd beast, and I might do some more
investigation. However, all you need to know is that in order to
remove, say the 5th element from a SList, you need to do this:
SList!int s = [1,2,3,4,5,6,7,8,9,0];
auto r = s[0..4];
auto r1 = take(1, r);
s.linearRemove(r1)
Not the most intuitive way in the world...
--
James Miller
t fits into that properly, but it shouldn't be too hard.
Also, remember that opDispatch takes the name of the function as the
last parameter, so watch out for that.
--
James Miller
e on `@property`s).
> fm.list = (1, "abc", 4L, 3.33);
I'm hoping you mean `fm.list = [1, "abc", 4L, 3.33];` I think that
using the right template parameters, you can use the same code for
(T...)(T el) and (T)(T[]), I just can't remember what that is...
> Another question :
> How do I bring in :
>
> opDispatch(string name, T) (T[] t)
--
James Miller
ne comment on this?
The flags you want are -O2, -inline -release.
If you don't have those, then that might explain some of the slow down
on slicing, since -release drops a ton of runtime checks.
Otherwise, I'm not sure why its so much slower, the druntime array ops
are written using SIMD instructions where available, so it should be
fast.
--
James Miller
en usages of strings, no strange other
usages of the same escape sequence...
--
James Miller
On Mar 20, 2012 1:50 AM, "bearophile" wrote:
>
> James Miller:
>
> > writeln(v1 == 1); //false
> > writeln(v1 == 1.0); //false
> > writeln(v1 == 1.0f); //false
> > writeln(v1+1 == 2.0f); //true
>
> Maybe I'd l
and can show that the type of `v1` is `float`, as you'd
expect. And the last one passes fine, as does doing `(v1+1)-1 == 1`.
I'm not sure what could be causing this. I believe it may be a bug,
but I would like to see if I'm just wrong instead.
--
James Miller
d it made me misread the last phrase as "threatening to
> eat your face". :-P
That too
--
James Miller
moment it is peacful and helpful, the next
it is scary and threatening to eat your files.
Also, git-svn isn't actually that bad...
--
James Miller
assert(parse!uint(s2, 16) == 0xff); // fail, it's 0
> }
>
> I think parse should pop the first two characters if the string starts with
> 0x.
>
>
> Side-note, it would be nice if std.string.isNumeric took a radix. :)
I agree, seems like a bug to me.
--
James Miller
On 8 March 2012 23:16, Matthias Walter wrote:
> On 03/08/2012 10:48 AM, James Miller wrote:
>> On Thursday, March 08, 2012 10:21:48 Matthias Walter wrote:
>>> but the following did not work:
>>>
>>> std.algorithm.swap(arrayInstance[i], arrayInstance[j]);
eturn a value is used here and there in
> http://dlang.org/iasm.html
For 1. I'd say that it would probably work, but you can't necessarily
rely on that, you may have to live with a bit of code duplication.
For 2. It seems that it should be fine, I can't check it right now,
but I would be surprised if it didn't compile and run.
--
James Miller
On Thursday, March 08, 2012 10:21:48 Matthias Walter wrote:
>but the following did not work:
>
>std.algorithm.swap(arrayInstance[i], arrayInstance[j]);
What error did you get exactly? Since that exact call should work. "It
didn't work" doesn't help.
--
James Miller
a static if somehow?
I don't think there is an 'elseif' for versions, probably because you
are normally checking mutually exclusive version descriptions.
Otherwise, its probably a good idea to keep the syntax as is, since it
stops people from abusing the mechanic.
--
James Miller
ned integer?
>
> I really don't get it...
>
> It's like déjà-vu all the time in this newsgroup.
Its the semantics in C/C++ and D explicitly tries to have the same
semantics as them. From what I remember its to aid people moving from
those language to D.
--
James Miller
owing negatives is clearly
>> > better and more intuitive.
Because you don't describe things as -5 metres tall, so you don't
describe things as -1024 bytes long. size_t makes sense unsigned
because negatives make no sense for size.
However, if you cast array.length to an int, it may work, haven't tested it.
--
James Miller
On 7 March 2012 14:47, Tyler Jameson Little wrote:
>
>> You shouldn't have to do anything with them, just write bindings for
>> the api, with all the correct types.
>>
>> --
>> James Miller
>
>
> Thanks! I guess I got a little over-zealous in portin
x27;t
> find:
>
> sys/types.h
> netinet/in.h
>
> Do these already exist?
sys/types is part of the C runtime if I remember correctly, and
netinet/in.h is part of the Unix networking interface.
You shouldn't have to do anything with them, just write bindings for
the api, with all the correct types.
--
James Miller
On 2 March 2012 18:52, Alex Rønne Petersen wrote:
> Hi,
>
> Are there any actively-maintained Cocoa bindings for D?
>
> --
> - Alex
Not as far as I know.
You should make some!
--
James Miller
available is missing the point. Hell bitfields
are provided by templates, so they aren't even a part of the language,
they are just a library feature.
Hope that helps
--
James Miller
At some point, you
have to concede design purity to convenience, otherwise you have a
language that is actively hostile to changing designs. *In best
"nagging wife" voice* "You should have used an Appender from the
start. Now you have to go change all that code. Its your own fault
really."...
--
James Miller
Obviously you need to do a reasonable job, but it is only
writing function prototypes, so there's not much that can go wrong.
--
James Miller
On 29 February 2012 20:21, Jos van Uden wrote:
> On 29-2-2012 7:06, James Miller wrote:
>>
>> On 29 February 2012 18:51, jic wrote:
>>>
>>>
>>> Greetings!
>>>
>>> I have this program,
>>>
>>> import std.process : s
> Yes. Tested on x32, and it works just fine. I'll use ia32libs and -m32 for
> the time being then.
>
> A strange thing is that memory consumption went _up_ when everything was
> compiled as x32.
I don't know much, but wouldn't bigger register sizes mean that less
data needs shuffled in and out of memory? Resulting in less
instructions and therefore less memory usage?
I'm just guessing though
--
James Miller
ror on your shell,
saying that it cannot find the command 4#.
Its because '&' is a special character used to fork a process into the
background, useful for gui programs and the like.
I have tried your code, using a *nix shell, and using 3\& works.
If you are on Windows, then I don't know why this is happening.
--
James Miller
t;class template" etc...
>
Not really, there might be, but not an obvious one. Its because
templates can hold multiple types of declarations, not just functions
or classes. The "eponymous template" pattern you see normally is not
mandatory.
--
James Miller
n functionality to the
base class, then add specific functionality to the individual classes.
It also allows for more reflection, which is easier and probably more
powerful than conditional compilation.
--
James Miller
On 26 February 2012 21:28, Jabba Laci wrote:
> Hi,
>
> I'm new to D. I tried the basic Hello World program ("dmd hello.d")
> but it produced a 316 KB big binary. The same thing with C ("gcc
> hello.c") is about 9 KB. Is there a way to reduce the size of the
> produced binary?
>
> Thanks,
>
> Laszl
On Feb 25, 2012 12:16 PM, "Caligo" wrote:
>
> That was a typo, and it doesn't change anything. Here is a shorter
version:
>
> 8<8<
> import std.datetime;
> import std.stdio;
>
> struct A{
>
> auto fun(A a){ return 0; }
> }
>
> void bench(alias fun)
7;t. You're right. I guess I have a long way to go to learn
these things.
>
> Thank you. Even at my primitive level, though, I can see how awesome
these things could be once you know how to program them. Does any other
language come close to D in terms of generics? I don't know, I'm just
asking?
>
> Zach
Lisp macros. But that's not a fair comparison, Lisp's object system was
built using their macros...
--
James Miller
On 24 February 2012 12:06, H. S. Teoh wrote:
> On Fri, Feb 24, 2012 at 04:06:52AM +1300, James Miller wrote:
>> On 23 February 2012 13:15, BLM wrote:
>> > After messing around for a while, I figured out what is making DMD choke
>> > on my
>> > file. The me
implib.html and has this:
/s[ystem] - Prepend '_' to exported internal names. Used to create
import library from Windows NT system DLLs (for example,
kernel32.dll). Note that this switch is not available via the ID
I hope that helps, I don't actually do any windows programming so I
can't test this at all
--
James Miller
)?
I don't know the answers to 1 or 2, but I know that there is a GC
class with a bunch of methods on it for controlling the GC, including
enabling and disabling it and getting GC-allocated memory. Whether
that helps you write GC predictable code - I don't know, garbage
collection is mostly a black art to me :-)
--
James Miller
I find that when learning a complicated system or library, the best
way is to write out the code examples, compile them, then change
things until they break, fix it, then make more changes. Eventually
you end up with the worst code ever known to man and a thorough
understanding of the system at han
ases
> are all in the same piece of code :)
And the award for "Most Meta Code" goes too...
--
James Miller
On 23 February 2012 23:35, simendsjo wrote:
> Say i have a c function (didn't include first format argument for
> simplicity)
>
> void print(...);
> I wrap it up:
> extern(System) void print(...);
>
> And then I try to wrap it up in some safer D way:
> void print(Args...)(Args args)
> {
> print
to learn the language in more depth :)
>
> We don't mind. :-)
>
>
> T
>
> --
> Truth, Sir, is a cow which will give [skeptics] no more milk, and so
> they are gone to milk the bull. -- Sam. Johnson
Just don't start asking too stupid questions (like how does 1+1 work?) :P.
--
James Miller
On 22 February 2012 17:01, Andrej Mitrovic wrote:
> class Foo
> {
> this(int) inout
> { }
>
> Foo makeFoo() { return new Foo(1); }
> }
>
> void main() { }
>
> test.d(8): Error: cannot implicitly convert expression (new Foo(1)) of
> type inout(Foo) to test.Foo
>
> Is this a bug?
I have no
On 22 February 2012 04:45, Dmitry Olshansky wrote:
> On 21.02.2012 7:34, James Miller wrote:
>>
>> On 20 February 2012 21:34, Dmitry Olshansky wrote:
>>>
>>> 08.02.2012 13:07, James Miller пишет:
>>>
>>>>
>>>> Hi,
>>>
On 18 February 2012 05:30, Jonathan M Davis wrote:
> On Friday, February 17, 2012 14:44:42 Mars wrote:
>> On Friday, 17 February 2012 at 13:33:25 UTC, James Miller wrote:
>> > AAs don't keep the key order, so when you delete something out
>> > of it,
>> &
On 20 February 2012 21:34, Dmitry Olshansky wrote:
> 08.02.2012 13:07, James Miller пишет:
>>
>> Hi,
>>
>> I am using std.regex and using the named matches. I would like to be
>> able to get at the names that have matched, since this is library
>> code.
>
I use vim, and I find that just vanilla vim does the job fine for me.
I don't tend to use autocomplete unless its really smart (like using
clang-complete for C/C++), and I should probably grab the latest D
syntax file. mostly just judicious use of "/" and "gg" gets me
most places.
AAs don't keep the key order, so when you delete something out of it,
what ever system iterates to the next pointer gets confused. Its
generally a bad idea to modify an array as you loop through it.
--
James Miller
On 15 February 2012 12:12, H. S. Teoh wrote:
> On Tue, Feb 14, 2012 at 11:47:52PM +0100, Timon Gehr wrote:
>> [...]
>> It does not hurt at all if your code base is more flexible than
>> necessary.
> [...]
>
> This needs to be taken in moderation, though.
>
> I've had to work with code that was unn
data flow. The advantage of
event-based systems is that you can be waiting for data from the
server and for user input at the same time, meaning that a slow server
doesn't break your client or render it unusable. If the code works for
you, then its probably fine.
James Miller
On 14 February 2012 12:45, Ali Çehreli wrote:
> On 02/13/2012 03:34 PM, James Miller wrote:
>
>> Saying "it is not quicksort as much as it may conceptually resemble
>> quicksort" is kinda odd, its like saying "it is not a car, as much as
>> it may conceptu
On 14 February 2012 12:26, Jonathan M Davis wrote:
> On Monday, February 13, 2012 15:12:15 H. S. Teoh wrote:
>> I discovered something really cool today, and I thought I'd share it
>> with my fellow learners:
>>
>> The unittest block is used for inserting unit tests that are executed at
>> runtime
On 14 February 2012 06:25, Timon Gehr wrote:
> On 02/13/2012 03:19 PM, James Miller wrote:
>>
>> On 11 February 2012 10:45, Jonathan M Davis wrote:
>>>
>>> On Friday, February 10, 2012 13:32:56 Marco Leise wrote:
>>>
>>>> I know that fe
On 11 February 2012 10:45, Jonathan M Davis wrote:
> On Friday, February 10, 2012 13:32:56 Marco Leise wrote:
>> I know that feeling. I had no exposure to functional programming and
>> options like chain never come to my head. Although "map" is a concept that
>> I made friends with early.
>
> It w
.captures.names;
or something similar. I've looked at the library and I can't find
anything of the sort, and you can't even use `foreach` to get at them
that way, I'm guessing because you can have both integer and string
indexes for the matches.
Thanks
James Miller
char_array:\t%s",
to!string(hasSwappableElements!(typeof(char_array;
writefln("hasSwappableElements ubyte_array:\t%s",
to!string(hasSwappableElements!(typeof(ubyte_array;
}
The output is
isBidirectonalRange char_array: true
isBidirectonalRange ubyte_array:true
hasSwappableElements char_array:false
hasSwappableElements ubyte_array: true
So if just just need an array of bytes and the `char' semantics are
unimportant, then you can just use a ubyte instead. However Timon is
correct that there should probably be a narrow string version of
`reverse'.
James Miller
68 matches
Mail list logo