Quantcast

empty string with C"

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

empty string with C"

Marcos Cruz

Is this a bug?

1) OK:

  C" "

2) ERROR ( 2" not found because the first C" ignores the first "):

  C" " C" 2"

3) OK:

  C" 1" C" 2"

4) OK (one space in the first string):

  C"  " C" 2"

I know both strings are stored in the same address, but I don't understand why
the second example fails. It should store an empty string.

Spasiva
Marcos

--
http://programandala.net

------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Spf-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spf-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: empty string with C"

Ruvim Pinka
Hello!

On Mon, Jun 13, 2011 at 11:12 PM, Marcos Cruz <[hidden email]> wrote:

Is this a bug?

1) OK:

 C" "

2) ERROR ( 2" not found because the first C" ignores the first "):

 C" " C" 2"


Yes, it is a bug. It has been fixed just now.

 
3) OK:

 C" 1" C" 2"

4) OK (one space in the first string):

 C"  " C" 2"

I know both strings are stored in the same address,

By the DPANS94, "interpretation semantics for this word are undefined".  This same address doesn't matter for compilation.

The c-addr u representation and the S" word are preferred.


but I don't understand why the second example fails. It should store an empty string.

Please, see the diff.
Thank you for the bug-report.

--
Ruvim

------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Spf-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spf-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: empty string with C"

Marcos Cruz
En/Je/On 2011-06-14 22:46, Ruvim Pinka escribió / skribis / wrote :

>      2) ERROR ( 2" not found because the first C" ignores the first "):
>
>       C" " C" 2"
>
>    Yes, it is a bug. It has been fixed just now.

>    The c-addr u representation and the S" word are preferred.

I know. But in my program i use C" to choose a random string:

: drops  ( x1..xn n -- )  
        0  do  drop  loop
        ;
: choose  ( x1..xn n -- xn' )
        dup >r random pick r> swap >r drops r>
        ;
: random_text  ( -- a u )
        c" text 1"
        c" text 2"
        c" text 3" 3 choose count
        ;

I can use S" but then the word DCHOOSE is a bit more complicated:

: dchoose  ( d1..dn n -- dn' )
        dup >r random 2*  ( d1..dn n' -- ) ( r: n )
        dup 1+ pick swap 2+ pick swap  ( d1..dn dn' -- ) ( r: n )
        r> rot rot 2>r  2* drops  2r>
        ;
: random_text  ( -- a u )
        s" text 1"
        s" text 2"
        s" text 3" 3 dchoose count
        ;

спасибо
Marcos

--
http://programandala.net

------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Spf-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spf-dev
Loading...