Re: string to char*

2010-09-11 Thread Jonathan M Davis
On Saturday 11 September 2010 09:07:38 bearophile wrote: > I don't know why it returns a const(char)* instead of a char*. Do you know > why? > > Bye, > bearophile Well, if you look at toStringz()'s implementation, you may notice that there's commented out code which would not make a copy if ther

Re: Generic collection/element function signatures in D2 versus D1

2010-09-11 Thread Brad Roberts
On 9/11/2010 9:32 PM, Nick Sabalausky wrote: > "Jacob Carlborg" wrote in message > news:i5t61q$2j7...@digitalmars.com... >> >> If you're not going to modify the content of the array I think this will >> work: >> >> void foo (T) (const(T)[] collection, T elem) {} >> >> This will allow both mutabl

Re: Generic collection/element function signatures in D2 versus D1

2010-09-11 Thread Nick Sabalausky
"Jacob Carlborg" wrote in message news:i5t61q$2j7...@digitalmars.com... > > If you're not going to modify the content of the array I think this will > work: > > void foo (T) (const(T)[] collection, T elem) {} > > This will allow both mutable, immutable and const arrays. But it will not > let yo

Re: Input handling? (newbie alert!)

2010-09-11 Thread Jonathan M Davis
On Saturday 11 September 2010 13:54:19 Cavalary wrote: > Hm, to me "informatics" made sense :) Not sure if I ever heard it > used in English, but it sounds more suitable than "computer > science", which (no matter how it's officially used) sounds like > it would include everything that deals with c

Re: Input handling? (newbie alert!)

2010-09-11 Thread Cavalary
Hm, to me "informatics" made sense :) Not sure if I ever heard it used in English, but it sounds more suitable than "computer science", which (no matter how it's officially used) sounds like it would include everything that deals with computers, so hardware as well. As for what Jesse said, yeah, k

Re: Input handling? (newbie alert!)

2010-09-11 Thread Jonathan M Davis
On Saturday 11 September 2010 08:51:11 bearophile wrote: > Jonathan M Davis: > > You mean computer science? That's the English term - in the US at least. > > http://en.wikipedia.org/wiki/Informatics_%28academic_field%29 > Most of "Computer Science" is not about computers, and most of it is not a >

Re: string to char*

2010-09-11 Thread bearophile
shd: > I'm having a problem in passing a value to char* expecting function > in D 2.0. Already tried: > to!(char*)("my string"); A solution, maybe correct: import std.string: toStringz, indexOf; import std.c.string: strlen; import std.stdio: writeln; void main() { string s = "my string";

Re: Input handling? (newbie alert!)

2010-09-11 Thread bearophile
Jonathan M Davis: > You mean computer science? That's the English term - in the US at least. http://en.wikipedia.org/wiki/Informatics_%28academic_field%29 Most of "Computer Science" is not about computers, and most of it is not a science. It's more a cross between mathematics and engineering. By

Re: opIndex() overloading for multiple arrays

2010-09-11 Thread Nrgyzer
Thanks for reply... exactly, what I need.

Re: string to char*

2010-09-11 Thread Andrej Mitrovic
I'm interfacing with Scintilla (C++), but it works in a different way. It uses messages, which allows it to be linked with practically any language. But I can still pass parameters to be modified by passing the address of the variable instead (the wrapper takes care of that). Although linking with

Re: string to char*

2010-09-11 Thread Mariusz GliwiƄski
On 2010-09-11 15:13, Simen kjaeraas wrote: Why does the function expect a char*? If it is an external C function, and it might change the passed values, you should make a duplicate mutable string, or use char[] in lieu of string. If it is an external C function that will *not* change the passed

Re: opIndex() overloading for multiple arrays

2010-09-11 Thread Simen kjaeraas
On Sat, 11 Sep 2010 15:30:33 +0200, Nrgyzer wrote: Hey guys, is it possible to overload opIndex() with a multiple array, for example: class Example { ... char[] opIndex(uint index1, uint index2) { return "my text to return"; } ... } Example t = new Example(); writefln(t[0][10]); Looking for

opIndex() overloading for multiple arrays

2010-09-11 Thread Nrgyzer
Hey guys, is it possible to overload opIndex() with a multiple array, for example: class Example { ... char[] opIndex(uint index1, uint index2) { return "my text to return"; } ... } Example t = new Example(); writefln(t[0][10]); Looking forward to hearing from anyone :)

Re: string to char*

2010-09-11 Thread Simen kjaeraas
shd wrote: Hello, I'm having a problem in passing a value to char* expecting function in D 2.0. Why does the function expect a char*? If it is an external C function, and it might change the passed values, you should make a duplicate mutable string, or use char[] in lieu of string. If it is

string to char*

2010-09-11 Thread shd
Hello, I'm having a problem in passing a value to char* expecting function in D 2.0. Already tried: to!(char*)("my string"); but it seems like there (Phobos) is no template like this. Then, tried: cast(char*)to!(char[])("my string") which looked ok, but i think it's not a proper way to do that.

Re: slow runtime

2010-09-11 Thread bearophile
Jonathan M Davis: > In any case, if you're looking to avoid GC collection cycles, it sounds like > std.gc.disable() and std.gc.enable() will help. But remember that that will > increase the odds that it will have to allocate more memory from the OS, > which > isn't cheap either. It's almost ce