Re: std.zlib and other tools

2011-03-03 Thread Jesse Phillips
I must have been overwhelmed when I landed on that page last time. Seems the etc.c.zlib bindings have the needed functions, just don't have it wrapped in the standard library. Thanks.

Re: DMD on linux? (more problems)

2011-03-02 Thread Jesse Phillips
Sean Eskapp Wrote: > I'm still having issues with the linux dmd. Here's the relevant part > of the output: > > ... > function func > function func > gcc Nullimorphism.o -o Nullimorphism.exe -g -m32 -l -Xlinker - > L/usr/lib32 -Xlinker -L/usr/lib64 -Xlinker --no-warn-search-mismatch > -Xlinker -

std.zlib and other tools

2011-03-02 Thread Jesse Phillips
I'm just wondering if anyone else has an issue with using std.zlib with other programs such as gzip and 7-zip? zlib creates and loads gz files right? The library works perfectly with itself, but I can't read or write compressed files from other popular programs. mport std.stdio; import std.file

Re: Ini parsing library in D ?

2011-02-28 Thread Jesse Phillips
Jesse Phillips Wrote: > It doesn't take much to make it work with D2. I have a working one, and has > mention of what I changed so I should be able to redistribute it. I'll double > check though. Here it is: https://github.com/he-the-great/ini.d/tree/D2 The master bran

Re: Ini parsing library in D ?

2011-02-28 Thread Jesse Phillips
Tarun Ramakrishna Wrote: > Err ok, I got excited too soon. That seems to be a D1 module..anyways > I am already halfway through writing my D2 Ini parser, so I guess its > fine > > On Mon, Feb 28, 2011 at 6:07 PM, Tarun Ramakrishna wrote: > > Hi Trass, > > > > Wow! A pure, plain simple D module f

Re: How do you test pre-/post-conditions and invariants?

2011-02-25 Thread Jesse Phillips
Magnus Lie Hetland Wrote: > Or, more generally, how do you test asserts (which is what I'm using in > my preconditions etc.)? > > As far as I can see, collectException() won't collect errors, which is > what assert() throws -- so what's the standard way of writing unit > tests for precondition

Re: implicite deref on array element access? (indexing)

2011-02-25 Thread Jesse Phillips
spir Wrote: > Hello, > > I thought it worked, just like implicite deref on (struct, class) member > access. But I cannot have it work: > > auto a = [1,2,3]; > auto pa = &a; > writeln((*pa)[2]); // ok > writeln(pa[2]); // segfault You aren't making a pointer to

Re: override to!string

2011-02-25 Thread Jesse Phillips
spir Wrote: > Hello, > > Imagine I have the following custom type: > alias float[] Numbers; > > Is it possible to override to!string for Numbers so that it outputs eg like; > (1.1 2.2 3.3) > ? No, this is one reason for writeTo replacing toString, or whatever the name. It would all

Re: C++ to D: Help please

2011-02-24 Thread Jesse Phillips
Well I guess my point was to use a language you are very familiar with to obtain examples. There have been some attempts and such tutorials: http://www.prowiki.org/wiki4d/wiki.cgi?ComingFrom#SpecificLanguage But Java I think is the most thorough and out of date (pre-D1). There is also a porting

Re: C++ to D: Help please

2011-02-24 Thread Jesse Phillips
%u Wrote: > I have no problems converting small problems. Hence why I'm not > trying to convert small scripts. My problems are in understanding > the inner workings of multimodule programs, how to create them, > create the make file to use in comepiling them, and then since I'm > reading C/C++ (w

Re: std.xml empty element

2011-02-24 Thread Jesse Phillips
Tom Wrote: > Hi, how can I create an empty element with current D2 std.xml Element > implementation? > > stdout.writeln(new Element("foo")); // Shields instead of > > > Thanks in advance, > Tom; One issue with this is that you can not determine what can be shortened to this form without a

Re: What's wrong with this enum?

2011-02-23 Thread Jesse Phillips
Andrej Mitrovic Wrote: > // Works > enum : int[string] > { > Circle = ["CoolCircle":50] > } > > // Error: non-constant expression ["CoolCircle":50] > enum shapes : int[string] > { > Circle = ["CoolCircle":50] > } > > I can't find this in bugzilla. I believe it is because shapes.Ci

Re: Error when exiting program

2011-02-18 Thread Jesse Phillips
Joel Christensen Wrote: > I'm using some one else's bindings to a C library. > > The problem seems to be limited to D2 programs. > > Error as follows: > An exception was thrown while finalizing an instance of class jec2.bmp.Bmp > > I also get other errors at program exit. > > Thanks for any he

Re: opSlice and foreach with ranges

2011-02-17 Thread Jesse Phillips
Ali Çehreli Wrote: > > ... if the iterated object offers the slice operator with no arguments > lst[], __c is initialized with lst[] instead of lst. This is in order to > allow "extracting" the iteration means out of a container without > requiring the container to define the three iteration p

Re: class invariants and property declarations

2011-02-17 Thread Jesse Phillips
Jonathan M Davis Wrote: > Except that @property is for _functions_. You mark a function with @property > so > that it _acts_ like a variable. @property on a variable is _meaningless_. It > would be like marking a variable nothrow. It makes no sense. Neither should > be > legal. The fact that

Re: class invariants and property declarations

2011-02-16 Thread Jesse Phillips
Dmitry Olshansky Wrote: > Now to properties, this is actually shouldn't be allowed: > > @property int hours; > > @property is a annotation applied to functions (getter/setter), to allow > calling it with omitted () and a natural assign syntax like this: Why shouldn't it be allowed? While it

Re: regex escapes

2011-02-16 Thread Jesse Phillips
spir Wrote: > Hello, > > Which characters are to be escaped: > * inside [] classes > * outside such classes > ? > > Also, is there for D regexes a "free form" format (where whitespace can be > used > to present formats more legibly, but must be escaped as literals)? Though you are probably as

Re: ref vs out.

2011-02-14 Thread Jesse Phillips
Charles McAnany Wrote: > Hi, all. So I'm new to this whole contract thing. (I'm coming from C and > Java.) > I got the impression that using foo(out arg) means that arg is given its > default value, but other than that it's just like ref. So, here's the basic > code I have thus far. The init val

Re: regex start-of-line

2011-02-12 Thread Jesse Phillips
spir Wrote: > Hello, > > I have a regex bug in following conditions: users pass a series of regex > formats (strings) from which I create regex engines later used for lexing. To > ensure matching at start of (rest of) source, I prefix each format with '^'. > Right in most cases. But the follow

Re: "name" of enum members

2011-02-11 Thread Jesse Phillips
spir Wrote: > On 02/11/2011 06:49 PM, Jesse Phillips wrote: > > spir Wrote: > > > >> Hello, > >> > >> To denote a member 'm' of an enum 'e', one needs to write "e.m". Is there > >> a way > >> to get back th

Re: "name" of enum members

2011-02-11 Thread Jesse Phillips
spir Wrote: > Hello, > > To denote a member 'm' of an enum 'e', one needs to write "e.m". Is there a > way > to get back this "name"? > Here are my best trials: Maybe to!string(Enum.i) should return the enum name with it's field. This makes since because it is trying to return its name, and f

Re: foreach over string enum

2011-02-10 Thread Jesse Phillips
spir Wrote: > But in your example the symbol a does not look like a constant, instead it > the > loop variable. Do, how does it work? Magic. No really, the best I can tell is that the compiler will try to run the foreach loop at compile-time if there is something in the body that must be eva

Re: foreach over string enum

2011-02-10 Thread Jesse Phillips
spir Wrote: > On 02/10/2011 08:22 PM, Jesse Phillips wrote: > > enum FileName : string { > > file1 = "file1.ext", > > file2 = "file2.ext" > > } > > > > void main(string args[]) > > { > > foreach(a; __traits(allMembers,

Re: foreach over string enum

2011-02-10 Thread Jesse Phillips
Nrgyzer Wrote: > Hey guys, > > I'm trying to iterate over an enumeration which contains strings like > the this: > > enum FileName : string { > file1 = "file1.ext", > file2 = "file2.ext" > } > > I already found this article: http://lists.puremagic.com/pipermail/ > digitalmars-d/2007-July/021920

Re: Starting with D

2011-02-07 Thread Jesse Phillips
Julius Wrote: > Hi there, > i'm all new to D but not new to programming in general. > I'd like to try D but i didn't find a nice tutorial yet. > I don't want to read a whole book, I just want to get the basics so I can > start. > Can you help me find something like that? > > Best regards, Julius

Re: New to D: parse a binary file

2011-02-06 Thread Jesse Phillips
scottrick Wrote: > T[] rawRead(T)(T[] buffer); > > I understand that T is generic type, but I am not sure of the > meaning of the (T) after the method name. That T is defining the symbol to represent the generic type. It can have more than one and D provides other things like aliases... Another

Re: Asynchronous concurrency with reference types

2011-02-04 Thread Jesse Phillips
spir Wrote: > (I have few exp in the paradigm, so don't believe me.) > > It seems your problem is a typical case that cannot be safe as is. > Essentially, > IIUC, you want a shared set of data to be fed (more generally: mutated) from > a > thread, while another thread (here, the main one) pro

Re: unsigned int in for loops

2011-02-04 Thread Jesse Phillips
Ellery Newcomer Wrote: > I think this was the impetus for foreach_reverse, or at least it is one > place where it is pretty handy. Don't remember what all there is in D1, > but in D2 you could do something like > > foreach_reverse(i; 0u .. 10u){ > // iterates over 9,8,7 .. 1,0 > } There was so

Re: Asynchronous concurrency with reference types

2011-02-04 Thread Jesse Phillips
Peter Alexander Wrote: > Essentially, the work that doWork does needs to be returned to the main > thread asynchronously, and obviously in a thread-safe manner. > > What's the best way to do this? The above won't work because ~= isn't > atomic, so you can't do it on shared data. Disclaimer: I

Re: std.regex bug? My regex doesn't match what it's supposed to.

2011-02-03 Thread Jesse Phillips
Alex Folland Wrote: > The problematic string: > > Guaton_at_9min59sec.WAgame Might I suggest using a simpler regex? It gives the ability to do better error checking/reporting. Instead of adding all the misspellings for minute and second, just capture those locations as words and analyze them

Re: Foreach type infering only works up to 2 levels?

2011-02-02 Thread Jesse Phillips
Andrej Mitrovic Wrote: > Wow disregard this whole post. I've just realized how stupid that looks. > > Sorry. :) See, you have material for a tutorial. I know you wouldn't run out.

Re: Safer enum casts

2011-02-01 Thread Jesse Phillips
bearophile Wrote: > If I have an enum of chars, and I have a variable that contains a generic > char, I may want to convert the second to an instance of the first one, > safely (a normal cast is enough to do it unsafely). Is it a good idea to give > this purpose to to!() (this idea is currently

Re: Why does "*" cause my tiny regextester program to crash?

2011-01-30 Thread Jesse Phillips
Alex Folland Wrote: > I wrote this little program to test for regular expression matches. I > compiled it with in Windows with DMD 2.051 through Visual Studio 2010 > with Visual D. It crashes if regexbuf is just the single character, > "*". Why? Shouldn't it match the entire string? While

Re: github syntax hilighting

2011-01-27 Thread Jesse Phillips
Jacob Carlborg Wrote: > On 2011-01-26 23:10, Andrej Mitrovic wrote: > > On 1/26/11, Jacob Carlborg wrote: > >> It takes about 10 seconds to get syntax highlighting at the bottom of > >> the file in TextMate. > > > > Takes half a second in Scite, and in Vim I'm not noticing any delays. > > Inciden

Re: array of elements of various sybtypes

2011-01-26 Thread Jesse Phillips
> Right, casting a /single/ element works: > auto x = [cast(T0)(t1), t2]; > auto y = [t1, cast(T0)(t2)]; So I guess it was implemented as "Common type within the given set." > But to! fails: > auto x = [to!(T0)(t1), t2]; > auto y = [t1, to!(T0)(t2)]; > /usr/include/d/dmd/phob

Re: array of elements of various sybtypes

2011-01-26 Thread Jesse Phillips
spir Wrote: > Hello, > > This fails: > > class T0 {} > class T1 : T0 {} > class T2 : T0 {} > > unittest { > auto t1 = new T1(); > auto t2 = new T2(); > T0[] ts = [t1, t2]; > } > > Error: cannot implicitly convert expression (t1) of type __trials__.T0 to > __trials__.T2 > Error:

Re: github syntax hilighting

2011-01-26 Thread Jesse Phillips
Well I found this, but it says the bug was fixed: http://support.github.com/discussions/site/157-syntax-highlighting-not-working-for-one-file Steven Schveighoffer Wrote: > Anyone have any clue why this file is properly syntax-aware: > > https://github.com/D-Programming-Language/druntime/blob/ma

Re: C# code sample

2011-01-26 Thread Jesse Phillips
Kagamin Wrote: > pragma Wrote: > > > i guess the D equivalent to IEnumerable is Range? how would it look like in > > D? > > Usually there's a little need for a range in such case. IEnumerable is > usually used because there's a high need for the List collection so it's used > even more often

Re: template magic

2011-01-25 Thread Jesse Phillips
spir Wrote: > On 01/25/2011 06:03 PM, Simen kjaeraas wrote: > > > > Of course, given a non-template function, it is impossible to safely > > pass a function to it. > > Dont you count this as typesafe function passing? > void writeRounding (int function (float) roundingScheme) {...} He mean

Re: C# code sample

2011-01-25 Thread Jesse Phillips
Mandeep Singh Brar Wrote: > How about simply saying: > > void foo(double[] data) > { >foreach (d; data) >{ > do_some_stuff(d); >} > } > > all ranges are already foreachable. > > Regards > Mandeep He is iterating over a range/iterable of double[], Simen got the type check wron

Re: template magic

2011-01-25 Thread Jesse Phillips
Trass3r Wrote: > > 2. What is the reason for Phobos defining param funcs as template > params? > > Correct me if I'm wrong but there's no way to pass an arbitrary > function to a function in a type-safe way. If you use pointers and > casts you can't check if the passed function meets certain > re

Re: C# code sample

2011-01-24 Thread Jesse Phillips
Simen kjaeraas Wrote: > pragma wrote: > > > Hi i come from a c# background > > > > I would like to write the following code in the according D style but > > i'm not > > sure howto do it > > > > c# code: > > void foo(IEnumerable data) > > { > > foreach (var d in data) > > { > > do_some_

Re: toString why not const

2011-01-21 Thread Jesse Phillips
Tom Wrote: > Hi, I'm trying to override Object's toString. I've noted it isn't a > const method, namely: > > string toString() const; > > This cause me troubles when using it on a const reference. > > Shouldn't it be const? > > Thanks, > Tom; Phobos hasn't become very const aware. There have

Re: Type-qualified functions?

2011-01-21 Thread Jesse Phillips
Sean Eskapp Wrote: > > > templates: > > > void foo(T)(T, void delegate(T) fn) > > { > > } > > > This parameterizes foo based on T, which could be A, const A, or int, or > > whatever works to compile the function. > > What if the parameters are more general, for instance the first parameter is

Re: Source code annotations alla Java

2011-01-20 Thread Jesse Phillips
Justin Johansson Wrote: > Thanks for answer. I wasn't expecting many enlightening responses. > Yours was a pleasant reply, albeit a reflection of the current state of D. > > - Justin I think it is worth mentioning that the current syntax comes from DIP 6 http://www.prowiki.org/wiki4d/wiki.cgi

Re: Detecting at compile time if a string is zero terminated

2011-01-20 Thread Jesse Phillips
I would bet that you'd end up spending more time translating the string then copying it. Didn't think to look at what type the function accepted. I figured that any such optimization would exist inside of toStringz if it was possible.

Re: Detecting at compile time if a string is zero terminated

2011-01-19 Thread Jesse Phillips
First off no. Second, is their really going to be a performance gain from this. I wouldn't expect static strings to be converted very often. And last I will copy and past a comment from the source code: 198 /+ Unfortunately, this isn't reliable. 199 We could make this work if st

Re: const vs immutable

2011-01-18 Thread Jesse Phillips
Sean Eskapp Wrote: > In cases where they are the same, for instance declaring: > const int x = oldX + 5; > > vs > > immutable int x = oldX + 5; > > Or in non-class, non-array function parameters, does it make a difference > which is used? Use immutable, it documents the type better. And const

Re: std.container.Array/RefCounted(T) leaking memory?

2011-01-13 Thread Jesse Phillips
Thanks very nice info, just two guys babbling about things they've only read I guess, but you seem much better informed. Steven Schveighoffer Wrote: > I think all memory is allocated/deallocated from the OS via the sbrk/brk > system call: > > > brk() and sbrk() change the locati

Re: std.container.Array/RefCounted(T) leaking memory?

2011-01-13 Thread Jesse Phillips
Steven Schveighoffer Wrote: > But even so, malloc and free have the same property where they don't > always give back memory to the OS. IIUC, Linux can only change the size > of memory it wants, it cannot free pages in the middle of the block. > > -Steve Disclaimer: I don't know what I am t

Re: Casting between tuples

2011-01-12 Thread Jesse Phillips
Wow, missed the part where TypeTuples can hold values. I suggest looking into using Tuple from std.typecons. What you need to remember is that you are not casting the tuple, you are casting the data in the tuple which creates a completely different tuple. It seems you are trying to use the type

Re: Casting between tuples

2011-01-12 Thread Jesse Phillips
Sean Eskapp Wrote: > I have a variable of type TypeTuple!(int, int), and I want to convert all its > elements into a variable of type TypeTuple!(string, string). Is there a way to > do this? Using a loop fails compilation with "Error: Integer constant > expression expected instead of i". > > I'd

Re: Parse Time using std.date

2011-01-12 Thread Jesse Phillips
Mandeep Singh Brar Wrote: > Hi, > > Is there a way to parse a Time string like 15:45 to a Date structure. > Parse method in std.date returns it as invalid. As a hack it works by > prepending it with something like 1-1-1970. But is there a cleaner > way to it. > > Thanks > Mandeep No. Though std

Re: std.concurrency, or me?

2011-01-11 Thread Jesse Phillips
rwardRange. Otherwise it works as expected. 1. https://gist.github.com/774983 Jesse Phillips Wrote: > Reddit let me to this article walking through an example of Goroutines[1]. I > figured it could look about the same in D. So I set out to learn some > multi-threading. And what I ended up w

std.concurrency, or me?

2011-01-10 Thread Jesse Phillips
Reddit let me to this article walking through an example of Goroutines[1]. I figured it could look about the same in D. So I set out to learn some multi-threading. And what I ended up with[2] had an issue. The mailbox size seems to be extremely small. Currently I have set the size to 10,000 and

Re: use of regex -- PS

2011-01-09 Thread Jesse Phillips
If you want your regular expression which matches at the begging of the string you use ^ (carrot). A regex is for describing what it takes to make a match, if your regex doesn't use this than it can match anywhere in the string. So to me having a match and find is redundant. I mean what does fin

Re: use of regex

2011-01-09 Thread Jesse Phillips
spir Wrote: > Hello, > > After getting a MatchResult by calling match(source, engine): Seems that, if > match has failed, calling result.hit() throws an assertion error. Then, how > can I know whether match was successful? As there is always a matchResult > object returned. I'm looking for a k

Re: writef vs writeln and printing to the console

2011-01-08 Thread Jesse Phillips
Andrej Mitrovic Wrote: > Unfortunately I can't provide a simple test case, but I have a case where > using: > > writef("..\n"); > > inside a loop that runs a dozen times does not print out each line as the > statement is reached, instead it prints out everything at once when the > app

Re: Variants for interfaces

2011-01-07 Thread Jesse Phillips
Mandeep Singh Brar Wrote: > Hi, > > Is it possible to point a variable to an interface. The below code does not > compile. > > module testD; > import std.stream; > import std.stdio; > import std.variant; > > interface A { > void func1(); > } > class AC: A { > void func1() { >

Re: D Language info collected and combined into one CHM file.

2011-01-07 Thread Jesse Phillips
david wang Wrote: > Sorry, > > surrely that I've posted the attachment (CHM file), but I can not > see it. > > Does anyone can kindly help me to point out that how to transfer > chm file to this BBS? > > waiting for kindly reply. > > > David. http://docs.google.com or maybe http://prowiki.

Re: Wide characters are not printed properly

2011-01-05 Thread Jesse Phillips
Jun Wrote: > Thank you for the answer, Vladimir, but it didn't work. The code page of my > console was 949 which supports Korean characters. I tested with french and e > with ` (I don't know its name)was not printed properly. Both wstring dstring > resulted the same problem. I believe you need to

Re: What is an Effect?

2011-01-02 Thread Jesse Phillips
Manfred_Nowak Wrote: > docs: > | Expressions that have no effect, like (x + x), are illegal in > | expression statements. > > But what sorts of effects are meant with this? (x + x) performs a calculation and throws out the result. x = 42; x = 42; This is performing an assignment of the same v

Re: dmd compile with imported modules

2011-01-01 Thread Jesse Phillips
David Nadlinger Wrote: > On 1/1/11 2:42 PM, David Nadlinger wrote: > > There has been some discussion on this recently, but for now, rdmd > > should be the tool to use. > > Oh, if you are looking for a dedicated »build tool«, you might also want > have a look at xfBuild which was created to ma

Re: Examples using Tango

2010-12-29 Thread Jesse Phillips
Daren Scot Wilson Wrote: > On 12/29/10 17:05, Jesse Phillips wrote: > > > > > D2's Standard Library is still in flux. Several modules are deprecated and > > not properly marked. > > > Overall, it sounds like no one should be using D2 yet unless they ha

Re: Examples using Tango

2010-12-29 Thread Jesse Phillips
Daren Scot Wilson Wrote: > I've been interested for a long time in learning D and using it for image > processing and physics number crunching. Now I've got a few days in a row > to study. Unfortunately I'm getting stuck even with "Hello World" due to > most examples of D I find seem to be u

Re: helpful runtime error messages

2010-12-15 Thread Jesse Phillips
spir Wrote: > It was already compiled with -gc (removing this switch does not change > output). I get a line only for top-level call (the number above point to the > calling line in main). Sorry wasn't on a Linux box to test myself. It might have to do with the error occurring in main, so you

Re: helpful runtime error messages

2010-12-15 Thread Jesse Phillips
spir Wrote: > For the following prog, I get: > > int element(int[] elements, uint i) {return elements[i];} > void main () { > int[] elements = [3,2,1]; > auto e = elements[9]; > } > > s...@o:~/prog/d$ dmd -ofprog -w -debug -unittest -L--export-dynamic prog.d > s...@o:~/prog/d$ ./prog > c

Re: helpful runtime error messages

2010-12-14 Thread Jesse Phillips
spir Wrote: > Hello, > > > Am I the only one who gets, as only kind of runtime errors, spectacularly > helpful messages like: > > int f () {return 0;} > void main () { > assert (f() == 1); > } > ==> > s...@o:~/prog/d/Text$ ./__trials__ > core.exception.asserter...@__trials__(44): Assertion

Re: random access-range without lower-power range kinds?

2010-12-14 Thread Jesse Phillips
Lars T. Kyllingstad Wrote: > To avoid the boilerplate, you could write a mixin that defines the > iteration primitives for you. > > mixin template IterationFuncs() > { > int index; > bool empty() { return index == length; } > auto front() { return opIndex(index); } >

Re: Removing an object from a range

2010-12-13 Thread Jesse Phillips
Andrej Mitrovic Wrote: > Does anyone know if there's any way I can get special highlighting for > lambda functions in say, Vim? It gets hard to distinguish between > regular parameters and one-liner lambdas, if I could change the > background color of a lambda it could really help out.. Off the t

Re: Facing problems with Class Properties

2010-12-10 Thread Jesse Phillips
d coder Wrote: > > Ah.. Now I think I understand. > > > > This new code I have written will all be run at compile time. So in > > this case, the foreach statement inside the constructor would be > > reduced to a bunch of writeln statements at compile time and those > > writeln would be executed at

Re: Facing problems with Class Properties

2010-12-10 Thread Jesse Phillips
Jesse Phillips Wrote: > typeof() and is() are compile time constructs. Change your if statements to > static if. Just realized what the issue is. You are creating code as foreach becomes a static foreach when iterating a tupleof. (Yes steven it does work) This you are building code which

Re: Facing problems with Class Properties

2010-12-10 Thread Jesse Phillips
d coder Wrote: > The issue is that when I try to compile the program, I get the error > bug.d(10): Error: no property 'length' for type 'test.Bar' > > I am explicitly checking the field type, and I am making sure that the field > is an array type, before looking for its length. So I am not sure w

Re: String to enum

2010-12-10 Thread Jesse Phillips
useo Wrote: > Hi, > > does anyone know how I can cast a string to an enum which also > contains strings? For example: > > enum MyENUM : string { > > x = "123" > y = "456" > z = "789" > > } > > ... > > string myString = X; > to!(MyENUM)(myString); // Error: cannot implicitly convert > expres

Re: Calling C functions

2010-12-09 Thread Jesse Phillips
CrypticMetaphor Wrote: > On 12/9/2010 5:28 PM, Steven Schveighoffer wrote: > > > Yes please, and be sure to specify that it correctly does not compile on > > linux. http://d.puremagic.com/issues/enter_bug.cgi > > > -Steve > > Alright then! > > I submitted a my first bug report and added __gshare

Re: use of Class Invariants

2010-12-08 Thread Jesse Phillips
%u Wrote: > That is what I am missing, a stack trace. > How do I see a stack trace? dmd1(win) I don't think the Windows stack trace is compete yet. Works in Linux.

Re: C Bitfields in D

2010-12-07 Thread Jesse Phillips
Jonathan M Davis Wrote: > Okay. I'm trying to get some C code to be properly callable from some D code, > which naturally involves some extern(C) blocks. One of the types that I have > to > deal with looks something like this: > > typedef struct > { > unsigned i:1; > } my_s

Re: C++ istream / ostream equivalent ?

2010-12-02 Thread Jesse Phillips
I'm currently looking at ways to improve std.conv.to. And this might be a good area to improve std.conv.parse. For example parse could be made to look for a method static readFrom!(T)() if(isSomeString!T) and maybe to should take advantage of it. auto foo = to!A(someString); I'd have to requir

Re: Passing functions to functionals

2010-11-30 Thread Jesse Phillips
Lars T. Kyllingstad Wrote: > // Same as above, using template alias parameter. > auto eval(alias f, X)(X x) { return f(x); } > > // Test > void main() > { > int add2(int i) { return i + 2; } > assert (eval!add2(1) == 3); > } > > I'd be grateful if people w

Re: Calling class methods by pointers

2010-11-22 Thread Jesse Phillips
wrzosk Wrote: > The problem i see is that in funcptr there is real entry point for > method used, not the index in virtual table, so the polymorphism can't > work with that. > > As I have written - i don't know whether it is correct use for delegate. > Possibly the ptr, funcptr should be both

Re: defining in a module symbols for export

2010-11-22 Thread Jesse Phillips
spir Wrote: > === mod.d == > import std.stdio; > > struct S { > int i; > void speak() {writeln("i: ",this.i);} > } > === __trials__.d === > import mod; > > auto s = S(); > s.speak(); > s.i = 1; > writeln(s.i); > > void main () { > } Others have answered how to initialize variables, bu

Re: linking custom modules (dmd)

2010-11-18 Thread Jesse Phillips
Mike Parker Wrote: > Nothing. DMD automatically links with Phobos.lib when you compile your > app. Well, not really automatic, the dmd.conf/sc.ini file is read by dmd, and can be edited for other libraries/files/commands.

Re: Converting Fuse headers

2010-11-10 Thread Jesse Phillips
div0 Wrote: > You can still do the size check for the stat_t struct as well, > I always double check the size of structs when doing those conversions > as it's very easy to get it wrong. Ah, good idea. The test I have planned will be to set some values in the D struct, and see what is read by t

Re: Converting Fuse headers

2010-11-10 Thread Jesse Phillips
div0 Wrote: > Well done, glad you proved me wrong. > > It does seem unlikely that size_t is wrong, > though you can test it easily enough: > > compile a test C program to see what size it is and compare it to the D > version: > > void main() { > printf("sizeof: %d", sizeof(size_t)); > }

Re: Converting Fuse headers

2010-11-09 Thread Jesse Phillips
I have some good news! It works (Simplest test case). I spent several hours trying to track down where my code translation could be causing problems. And have concluded that core.sys.posix.sys.stat.stat_t is not correct for my 32bit Debian Linux machine. I realize this is a big claim, so I'm go

Re: Converting Fuse headers

2010-11-09 Thread Jesse Phillips
them being fuse /** Handle for a FUSE filesystem */ struct fuse; Can you forward declare a reference like this in D? If not does it matter what I define it to be? struct fuse {} // Since I'm really only passing pointers to this anyway. Sure hope this makes it work. > Jesse Phillips wrote:

Re: Converting Fuse headers

2010-11-09 Thread Jesse Phillips
div0 Wrote: > Well I don't like to discourage people, but a casual glance at your post > and the fuse headers suggests to me you don't have nearly enough > experience of C to succeed. Thank you for the input. And I already figured quit a bit of effort would go into answering. I considered aski

Re: Converting Fuse headers

2010-11-08 Thread Jesse Phillips
Jesse Phillips Wrote: > I'm trying to make fuse work in D[1]. I had some help from htod, but not > everything was successful. And I'm not exactly sure how to properly convert > strings and such. When saying D[1], I was referencing the link, not the version of D. But otherwise no suggestions?

Re: array of elements of various subclasses

2010-11-07 Thread Jesse Phillips
spir Wrote: > No, in fact a variadic param list is not an array -- this is according to > TDPL an iternal type of the language. Trying to assign it to an X[] var > throws: > DeeMatch.d(371): Error: cannot implicitly convert expression (patterns) of > type DeeMatch.Pattern to Pattern[] > Well, a

Re: array of elements of various subclasses

2010-11-07 Thread Jesse Phillips
spir Wrote: > On Sun, 7 Nov 2010 16:17:38 +0100 > spir wrote: > > And I'd like to know, as a possible workaround, if there is a way to save a > variadic arg list: > class C { > ??? xs; > this(X xs...) { > this.xs = xs; > } > } > > Denis >

Re: array of elements of various subclasses

2010-11-07 Thread Jesse Phillips
spir Wrote: > Hello, > > > Say I have some subclasses of Pattern. When I try to write > Pattern[] patterns = [x,y,z]; > I get an error because, apparently, D types the array according to the class > of z (Choice is here the type of z): > > DeeMatch.d(473): Error: cannot implicitly conver

Re: check type

2010-11-07 Thread Jesse Phillips
spir Wrote: > I just realised that what I was asking for is in fact class-level fields -- > common to all instances, instead of each instance having it locally. > Maybe you know the answer to that, but just in case you would use a static variable. class SC { static string f = "SC";

Converting Fuse headers

2010-11-06 Thread Jesse Phillips
I'm trying to make fuse work in D[1]. I had some help from htod, but not everything was successful. And I'm not exactly sure how to properly convert strings and such. What I currently have allows me to compile some fuse programs (hello for example[2]). But the result is a dead link (only seem t

Re: read-only access

2010-11-02 Thread Jesse Phillips
Steven Schveighoffer Wrote: > It does not say that functions should be callable without parentheses, > because that mis-feature is deprecated. Essentially, to someone who is > new to D, there is no need to mention the historical features of D. It > does say that you need to put @property o

Re: subclassing

2010-11-02 Thread Jesse Phillips
spir Wrote: > On Tue, 02 Nov 2010 12:33:16 -0400 > Jesse Phillips wrote: > > > spir Wrote: > > > > > > > * Why does D allow me redefining (data) slots in the subclass OddSquares, > > > which exist in the superclass? (I did this first without not

Re: read-only access

2010-11-02 Thread Jesse Phillips
Steven Schveighoffer Wrote: > On Tue, 02 Nov 2010 15:54:13 -0400, Jesse Phillips > wrote: > > > Calling functions without () is a legacy feature left over which is how > > D use to do properties. Some will say this is going to be removed, but > > do not recall

Re: subclassing

2010-11-02 Thread Jesse Phillips
Jonathan M Davis Wrote: > I should point out that you forgot the save property, which is required for > forward ranges (though not input ranges). Without it, any algorithm which > processes the range will consume it. Trying to ease this guy into ranges. I did notice though, the InputRange int

Re: read-only access

2010-11-02 Thread Jesse Phillips
spir Wrote: > Hello, > > Is the D way to make read-only symbols (of a class, struct, module) to write > a getter for a private symbols? Yes, though it isn't like the getValue() from java. @property int i() {return this.my_i;} > Additional question: just realised one can omit () on func calls

Re: subclassing

2010-11-02 Thread Jesse Phillips
spir Wrote: > * Why does D allow me redefining (data) slots in the subclass OddSquares, > which exist in the superclass? (I did this first without noting, by copy & > paste ;-) This is either a bug or so that you don't have name clashes with all the super classes (could really reduce the avai

Re: subclassing

2010-11-02 Thread Jesse Phillips
I'll come back with a more complete answer latter, but first. spir Wrote: > * I wrote Range as class, but I rather meant an interface. D does not let me > do that, apparently because there is no data slot in a D interface. Is then > an interface a kind of data-less superclass? Or is there somet

<    2   3   4   5   6   7   8   >