On Mon, 20 Jun 2011 02:48:30 +, Charles McAnany wrote:
> Hi, all. I'm looking for a way to make constants that have methods
> without a lot of overhead. In particular, a way to define a Direction
> and then be able to rotate it right. Here's kind of what I have in mind:
>
> enum Direction{
>
"Peter Alexander" wrote in message
news:itlk5g$e7t$1...@digitalmars.com...
> I've been having strange linker errors recently and I have no ideas why
> they've started happening.
>
> Undefined symbols:
> "_D3std9exception7bailOutFAyaixAaZv", referenced from:
> _D3std9exception148__T7enforceTb
On 2011-06-19 19:48, Charles McAnany wrote:
> Hi, all. I'm looking for a way to make constants that have methods
> without a lot of overhead. In particular, a way to define a
> Direction and then be able to rotate it right. Here's kind of what I
> have in mind:
>
> enum Direction{
> left, right, u
Doost : http://www.dsource.org/projects/doost
Has a serializer that can read value to and from JSon! ;)
"Johannes Pfau" wrote in message
news:20110619193834.2c6afdf7@jpf-Satellite-A100...
std.json doesn't work at all because of bug #2962 . I tried to remove
the problematic part from std.json
There is a remove() method in std.algorithm!I even got asked why I was
reimplementing it!
(well, because I didn't know it existed hey!)
works fine with, say, int...
but not with delegate!
associative array will solve the problem indeed.. (I hope) but they use way
more memory!
it would be nic
Hi, all. I'm looking for a way to make constants that have methods
without a lot of overhead. In particular, a way to define a
Direction and then be able to rotate it right. Here's kind of what I
have in mind:
enum Direction{
left, right, up, down;
public Direction rotateRight(){
switch(this){
Hi Robert and Dmitry,
Thanks for your replies and the heads up on the current status of DMDScript!
Josh
Johannes Pfau :
> The only difference is the argument order for dmd!
Aye, I saw this one when I updated to 2.053 now I
remember wasting an hour on that bug!
Bugzilla suggests for the workaround to just put a dummy module
in there as the first argument:
icehack.d
module icehack;
import s
I've been having strange linker errors recently and I have no ideas why
they've started happening.
When compiling/linking:
import std.stdio;
void main() { writeln("Hello"); }
with DMD 2.053 I get linker error:
Undefined symbols:
"_D3std9exception7bailOutFAyaixAaZv", referenced from:
_
Adam D. Ruppe wrote:
>Johannes Pfau wrote:
>> I guess you do not have similar helper functions to parse JSON?
>
>My other message has some. It isn't quite as nice to use though -
>getting structs and such takes a little bit of work.
>
>For example, I use it to get stuff from Facebook, and it
>looks
Johannes Pfau wrote:
> I guess you do not have similar helper functions to parse JSON?
My other message has some. It isn't quite as nice to use though -
getting structs and such takes a little bit of work.
For example, I use it to get stuff from Facebook, and it
looks kinda like this:
===
Adam D. Ruppe wrote:
>Oh, wait a minute, you were doing from json, not to json.
>
>Try this on for size. It converts from a std.json.JSONValue
>to a std.variant.Varaint, which is quite a bit simpler to use.
>
>==
>
>import std.variant;
>import std.json;
>
>Variant jsonToVariant(string json) {
>
Adam D. Ruppe wrote:
>I use std.json with a couple helper function to make it shorter.
>
>To use:
>
>writeln(toJson(whatever));
>
>or
>
>JSONValue val = toJsonValue(whatever);
>
>Works on most basic data types: int, string, array, assoc, struct,
>etc.
>
>=
>
>import std.json;
>import std.traits
Oh, wait a minute, you were doing from json, not to json.
Try this on for size. It converts from a std.json.JSONValue
to a std.variant.Varaint, which is quite a bit simpler to use.
==
import std.variant;
import std.json;
Variant jsonToVariant(string json) {
auto decoded = parseJSON(
I use std.json with a couple helper function to make it shorter.
To use:
writeln(toJson(whatever));
or
JSONValue val = toJsonValue(whatever);
Works on most basic data types: int, string, array, assoc, struct,
etc.
=
import std.json;
import std.traits;
import std.conv;
string toJson(T)(T
std.json doesn't work at all because of bug #2962 . I tried to remove
the problematic part from std.json and got it to compile (by disabling
support for floating point numbers...) but using it correctly creates
very verbose code:
-
Seems like gmail likes to cut my code. If that didn't paste well here:
http://codepad.org/cyEDHSGc
Remove takes an offset, not a value as far as I know.
If you need fast lookup and removal you could use hashes instead:
int main(string[] argv)
{
auto a = new A;
SlotDelegate x = &a.DIT;
bool[SlotDelegate] _slotDg;
_slotDg.remove(x);
return 0;
}
the following code seem problematic to compile...
import std.algorithm;
private alias void delegate(int, int) SlotDelegate;
class A
{
void DIT(int a, int b)
{
}
}
int main(string[] argv)
{
A a;
SlotDelegate x= &a.DIT;
SlotDelegate[] _slotDg;
_slotDg.remove(x);
ret
Never mind, just found it!
http://www.digitalmars.com/d/2.0/hash-map.html
I am creating a struct that I want to use as dictionary (associative array)
key
Initially it was a class and I overrode toHash and opCmp.
I just made it a struct to be more lightweight on the system, but can't
"override" toHash anymore!
How can I make it a good dictionary key?
Here is the stru
21 matches
Mail list logo