December 05, 2013
On Wednesday, 4 December 2013 at 23:03:10 UTC, Chris Cain wrote:

>
> Here's a version that does what (I think) you want:
>
> ----------
> string stripPar(string S)
> {
> 	while(S[0] == '(' && S[S.length-1] == ')')
> 	{
> 	
> 	      S = S[1 .. $ - 1];
> 	}
>
> 	return S;
> }
> ----------
>
> So, what this does is just changes the view of S, not the data of S. A subtle but important distinction.

First thank you soooo much for clarification of the operation.

however, i tried your solution too. this failed with the same errors as mentioned in the first post of the thread..
December 05, 2013
On Thursday, 5 December 2013 at 15:46:41 UTC, seany wrote:
> First thank you soooo much for clarification of the operation.

You're welcome.

> however, i tried your solution too. this failed with the same errors as mentioned in the first post of the thread..

You sure that you don't have some other problem?

file stripParTest.d:
---
import std.algorithm;

string stripPar(string S)
{
    while(S[0] == '(' && S[S.length-1] == ')')
    {
          S = S[1 .. $ - 1];
    }

    return S;
}

unittest {
    string testData = "((a)";
    string result = stripPar(testData);
    assert(equal(result, "(a"));
}
---

run with: rdmd -unittest -main stripParTest.d

Works fine for me.
December 05, 2013
On Thursday, 5 December 2013 at 16:38:11 UTC, Chris Cain wrote:
> On Thursday, 5 December 2013 at 15:46:41 UTC, seany wrote:
>> First thank you soooo much for clarification of the operation.
>
> You're welcome.
>
>> however, i tried your solution too. this failed with the same errors as mentioned in the first post of the thread..
>
> You sure that you don't have some other problem?
>
> file stripParTest.d:
> ---
> import std.algorithm;
>
> string stripPar(string S)
> {
>     while(S[0] == '(' && S[S.length-1] == ')')
>     {
>           S = S[1 .. $ - 1];
>     }
>
>     return S;
> }
>
> unittest {
>     string testData = "((a)";
>     string result = stripPar(testData);
>     assert(equal(result, "(a"));
> }
> ---
>
> run with: rdmd -unittest -main stripParTest.d
>
> Works fine for me.

I dont think i have other problems other than perhaps a bug in 2.061 dmd?

By the way does your solution edit the physical memory in place, or just change the way it is pointed to? in case of the second, is there an appropriate garbage collector?
December 05, 2013
On Thursday, 5 December 2013 at 16:59:50 UTC, seany wrote:
> I dont think i have other problems other than perhaps a bug in 2.061 dmd?

I'd definitely recommend upgrading to the latest release (2.064.2) since it has lots of bug fixes since 2.061. But if your code is still saying this (your original post):
> /home/apua/Software/dmd/dmd/src/phobos/std/algorithm.d(6992): Error: template std.algorithm.move does not match any function template declaration. Candidates are:
> ...

Then you're probably using your old code somewhere. The stripPars I've suggested does not use std.algorithm.move at all.

> By the way does your solution edit the physical memory in place, or just change the way it is pointed to?

It's just changing the view of the data.

Ali's book covers this stuff in more detail:
http://ddili.org/ders/d.en/index.html

specifically:
http://ddili.org/ders/d.en/slices.html

> in case of the second, is there an appropriate garbage collector?

D uses garbage collection by default and it's aware of and fine with this type of thing.
1 2
Next ›   Last »