help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: interesting results from char


From: Carlo De Falco
Subject: Re: interesting results from char
Date: Wed, 21 Jun 2017 15:14:39 +0000

> On 21 Jun 2017, at 15:17, Doug Stewart <address@hidden> wrote:
> 
> this first part I understand.
> 
> >> char [0xbb,0x36]
> parse error:
> 
>   syntax error
> 
> >>> char [0xbb,0x36]
>          ^
> 
> now for the correct way
> 
> >> char ([0xbb,0x36])
> ans = �6
> >>
> 
> 
> now for the interesting results!
> 
> >> q= char x=[ 0xbb,0x36]
> parse error:
> 
>   syntax error
> 
> >>> q= char x=[ 0xbb,0x36]
>             ^
> Ok this is definitely a syntax error
> 
> 
> now the unusual result.
> 
>  char x=[ 0xbb,0x36]
> ans = x=[ 0xbb,0x36]
> >> q=ans
> q = x=[ 0xbb,0x36]
> 
> So why when I try 
> q= char x=[ 0xbb,0x36]
> it is a syntax error  but
>  char x=[ 0xbb,0x36]
> is not a syntax error and the ans can be used as a string of "x=[ 0xbb,0x36]"
> 
> 
> Just curious!


I think this is related to the "command form" of Octave functions.
The interpreter parses 

 myfunction abcdef

as if you had typed 

 myfunction ("abcdef")

therefore 

 char x=[ 0xbb,0x36]

is treated as

 char ("x=[ 0xbb,0x36]")

c.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]