Something to ponder on a beautiful Saturday!

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Something to ponder on a beautiful Saturday!

David Marso
Administrator
Honey!
Hand me a cold one?
---
DEFINE Foo (BAR !CMDEND)
!DO !Oops !IN (!BAR)
ECHO !QUOTE (!OOPS).
!DOEND
!ENDDEFINE.
Foo BAR= 2006 2007 2008 2009 2010 2011 2011Priv 2012 2012Priv  .
 
DEFINE Foo (BAR !CMDEND)
 713  0 M>  DEFINE
 714  0 M>   Foo (BAR !CMDEND)
!DO !Oops !IN (!BAR)
 715  0 M>  !DO !Oops !IN (!BAR)
ECHO !QUOTE (!OOPS).
 716  0 M>  ECHO !QUOTE (!OOPS).
!DOEND
 717  0 M>  !DOEND
!ENDDEFINE.
 718  0 M>  !ENDDEFINE.
Foo BAR= 2006 2007 2008 2009 2010 2011 2011Priv 2012 2012Priv  .
 719  0 M>  
 720  0 M>  .
 721  0 M>  ECHO '2006'.
2006
 722  0 M>  ECHO '2007'.
2007
 723  0 M>  ECHO '2008'.
2008
 724  0 M>  ECHO '2009'.
2009
 725  0 M>  ECHO '2010'.
2010
 726  0 M>  ECHO '2011'.
2011
 727  0 M>  ECHO '2011'.
2011
 728  0 M>  ECHO 'Priv'.
Priv
 729  0 M>  ECHO '2012'.
2012
 730  0 M>  ECHO '2012'.
2012
 731  0 M>  ECHO 'Priv'.
Priv
 732  0 M>  .
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Something to ponder on a beautiful Saturday!

Kirill Orlov
David, what was the purpose? You found something funny or strange with the macro piece, didn't you?

Reply | Threaded
Open this post in threaded view
|

Re: Something to ponder on a beautiful Saturday!

David Marso
Administrator
In reply to this post by David Marso
Sending them in quoted works, but I can't see ANY reason why the
parser would split the token in this fashion!  WEIRD!

On 9/1/13, Albert-Jan Roskam <[hidden email]> wrote:

>
> ----- Original Message -----
>
>> From: David Marso <[hidden email]>
>> To: [hidden email]
>> Cc:
>> Sent: Saturday, August 31, 2013 11:38 PM
>> Subject: [SPSSX-L] Something to ponder on a beautiful Saturday!
>
> <snip>
>
>> Foo BAR= 2006 2007 2008 2009 2010 2011 2011Priv 2012 2012Priv  .
>
> <snip>
>
>> 725  0 M>  ECHO '2010'.
>> 2010
>> 726  0 M>  ECHO '2011'.
>> 2011
>> 727  0 M>  ECHO '2011'.
>> 2011
>> 728  0 M>  ECHO 'Priv'.
>> Priv
>> 729  0 M>  ECHO '2012'.
>> 2012
>> 730  0 M>  ECHO '2012'.
>> 2012
>> 731  0 M>  ECHO 'Priv'.
>> Priv
>> 732  0 M>  .
>
> That's weird indeed. How does it decide that the year and the suffix "must"
> be separated? Did you also try this with quoted arguments? (I don't have
> SPSS on this computer so I can't try this). That seems more logical to me as
> 'Priv' probably has no meaning (it's not a variable).
>
> Oh, and a cold one is always welcome. Make it two. ;-)
>
> Albert-Jan
>
>

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Something to ponder on a beautiful Saturday!

Andy W
In reply to this post by David Marso
If my memory serves me correctly I have encountered similar problems when trying to specify negative numbers as tokens to a function. (So the problem occurs the obverse way as well, if the text string is first and is followed by a number.)

Foo BAR= -2006 2007 2008 2009 2010 2011 2011Priv 2012 2012Priv  .
Foo BAR= 2006*-1 2007 2008 2009 2010 2011 2011Priv 2012 2012Priv  .
Andy W
apwheele@gmail.com
http://andrewpwheeler.wordpress.com/
Reply | Threaded
Open this post in threaded view
|

Re: Something to ponder on a beautiful Saturday!

Kirill Orlov
In reply to this post by David Marso
David,
Did I get you right that it was a surprise to you - that (unquoted) 2011priv is taken by a macro as two and not one word? This behaviour has been there for ages and ages: CharNum is one word but NumChar isn't. I suspect that the parser was such programmed intentionally, although I'm not sure about the reason. I personally also think that this feature brings little problem or inconvenience.

The real unconvenience though is that it can't read negative numeric value as one value. But you know why - macro haven't learnt to do math.

Reply | Threaded
Open this post in threaded view
|

Re: Something to ponder on a beautiful Saturday!

David Marso
Administrator
Kirill:
" I suspect that the parser was such programmed intentionally, although I'm not sure about the reason.."

I can think of NO good reason for this behavior.  It is an inconvenience since one must remember this odd irrational behavior and be sure to send in such arguments in quotes and remember to !UNQUOTE etc...!  

Kirill Orlov wrote
David,
Did I get you right that it was a surprise to you - that (unquoted)
2011priv is taken by a macro as two and not one word? This behaviour has
been there for ages and ages: CharNum is one word but NumChar isn't. I
suspect that the parser was such programmed intentionally, although I'm
not sure about the reason. I personally also think that this feature
brings little problem or inconvenience.

The real unconvenience though is that it can't read negative numeric
value as one value. But you know why - macro haven't learnt to do math.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Something to ponder on a beautiful Saturday!

Kirill Orlov
But it yet seems consistent with general SPSS's habits.

numeric a b1 c 3.
do rep word= a b1 2c 3.
print /word.
end rep print.
exec.

  80  0 +print          /a
  81  0 +print          /b1
  82  0 +print          /2
  83  0 +print          /c
  84  0 +print          /3
 
Lists in DO REPEAT can be any - varnames, values. And "2c" gets split, like in a macro.
So I think it is "intentional" because of some internal ideology, such as "A user surely intended 2 c and mistakengly put it as 2c".


02.09.2013 20:22, David Marso пишет:
Kirill:
" I suspect that the parser was such programmed intentionally, although I'm
not sure about the reason.."

I can think of NO good reason for this behavior.  It is an inconvenience
since one must remember this odd irrational behavior and be sure to send in
such arguments in quotes and remember to !UNQUOTE etc...!
Reply | Threaded
Open this post in threaded view
|

Re: Something to ponder on a beautiful Saturday!

Jon K Peck
What you are discussing is really the step before parsing, namely  tokenizing.  That is process of grouping sequences of characters into recognizable items such as variable names, operators, punctuation, and numbers.  The same tokenizer is used for regular Statistics syntax and macros for consistency.  However, a sequence such as nnnaaa where n is a digit and a an alpha character essentially does not exist in regular syntax, at least I can't think of such a beast (except for 2SLS as the name of the two stage least squares procedure).  The closest one might come is perhaps a number written in scientific notation.

However, the following statement is legal and does what you would expect.
compute z = 3lt 4.
FWIW.
It seems to me that something that does not follow the normal token rules should be handled as a quoted literal.


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: 720-342-5621




From:        Kirill Orlov <[hidden email]>
To:        [hidden email],
Date:        09/02/2013 10:54 AM
Subject:        Re: [SPSSX-L] Something to ponder on a beautiful Saturday!
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




But it yet seems consistent with general SPSS's habits.

numeric a b1 c 3.
do rep word= a b1 2c 3.
print /word.
end rep print.
exec.

 80  0 +print          /a
 81  0 +print          /b1
 82  0 +print          /2
 83  0 +print          /c
 84  0 +print          /3
 
Lists in DO REPEAT can be any - varnames, values. And "2c" gets split, like in a macro.
So I think it is "intentional" because of some internal ideology, such as "A user surely intended 2 c and mistakengly put it as 2c".


02.09.2013 20:22, David Marso пишет:
Kirill:
" I suspect that the parser was such programmed intentionally, although I'm
not sure about the reason.."

I can think of NO good reason for this behavior.  It is an inconvenience
since one must remember this odd irrational behavior and be sure to send in
such arguments in quotes and remember to !UNQUOTE etc...!