Csound Csound-dev Csound-tekno Search About

[Csnd] macro puzzle

Date2014-01-13 23:35
FromOeyvind Brandtsegg
Subject[Csnd] macro puzzle
How is it that $A is interpreted both as 'itest' and as the value 1 in
the csd below?
it prints
SECTION 1:
new alloc for instr 1:
instr 1:  ithisitest = 1.000







#define this(A)#
    ithis$A    = $A
    print ithis$A
#
    instr 1
itest = 1
$this(itest)
    endin



i1 0 1
e






-- 

Oeyvind Brandtsegg
Professor of Music Technology
NTNU
7491 Trondheim
Norway
Cell: +47 92 203 205

http://flyndresang.no/
http://www.partikkelaudio.com/
http://soundcloud.com/brandtsegg
http://soundcloud.com/t-emp

Date2014-01-14 05:31
FromTarmo Johannes
SubjectRe: [Csnd] macro puzzle
Hi,

if I were the parser, I think would see the code after macro replacement in 
the instr 1:

   instr 1
itest = 1
ithisitest = itest
print ithisisitest
    endin


so the result 
instr 1:  ithisitest = 1.000

makes perfectly sense to me.

But what you are after? Some extremely clever and economical code?

best!
tarmo


On Tuesday 14 January 2014 00:35:23 Oeyvind Brandtsegg wrote:
> #define this(A)#
>     ithis$A    = $A
>     print ithis$A
> #
>     instr 1
> itest = 1
> $this(itest)
>     endin

Date2014-01-14 08:55
FromOeyvind Brandtsegg
SubjectRe: [Csnd] macro puzzle
Ah, yes, thanks, it makes sense to me too now.
I was trying to create a minimal example of a problem I discovered in
some old code of mine, where I had nested macros using the same macro
name ($A as the argument of both macros, one being called inside the
other). Still trying, as the above code did not create problems...
best
Oeyvind

2014/1/14 Tarmo Johannes :
> Hi,
>
> if I were the parser, I think would see the code after macro replacement in
> the instr 1:
>
>    instr 1
> itest = 1
> ithisitest = itest
> print ithisisitest
>     endin
>
>
> so the result
> instr 1:  ithisitest = 1.000
>
> makes perfectly sense to me.
>
> But what you are after? Some extremely clever and economical code?
>
> best!
> tarmo
>
>
> On Tuesday 14 January 2014 00:35:23 Oeyvind Brandtsegg wrote:
>> #define this(A)#
>>     ithis$A    = $A
>>     print ithis$A
>> #
>>     instr 1
>> itest = 1
>> $this(itest)
>>     endin
>
>
> Send bugs reports to the Sourceforge bug trackers
> csound6:
>             https://sourceforge.net/p/csound/tickets/
> csound5:
>             https://sourceforge.net/p/csound/bugs/
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>
>



-- 

Oeyvind Brandtsegg
Professor of Music Technology
NTNU
7491 Trondheim
Norway
Cell: +47 92 203 205

http://flyndresang.no/
http://www.partikkelaudio.com/
http://soundcloud.com/brandtsegg
http://soundcloud.com/t-emp

Date2014-01-14 15:44
Fromjpff
SubjectRe: [Csnd] macro puzzle
The macrop exmansion takes place in the preprocessor and is textual.  The 
assignment to itest takes place at runtime; hence the results you see 
which are in my opiion correct.

==John


On Tue, 14 Jan 2014, Oeyvind Brandtsegg wrote:

> How is it that $A is interpreted both as 'itest' and as the value 1 in
> the csd below?
> it prints
> SECTION 1:
> new alloc for instr 1:
> instr 1:  ithisitest = 1.000
>
>
> 
> 
> 
> 
>
> #define this(A)#
>    ithis$A    = $A
>    print ithis$A
> #
>    instr 1
> itest = 1
> $this(itest)
>    endin
>
> 
> 
> i1 0 1
> e
> 
> 
>
>
>
>
> -- 
>
> Oeyvind Brandtsegg
> Professor of Music Technology
> NTNU
> 7491 Trondheim
> Norway
> Cell: +47 92 203 205
>
> http://flyndresang.no/
> http://www.partikkelaudio.com/
> http://soundcloud.com/brandtsegg
> http://soundcloud.com/t-emp
>
>
> Send bugs reports to the Sourceforge bug trackers
> csound6:
>            https://sourceforge.net/p/csound/tickets/
> csound5:
>            https://sourceforge.net/p/csound/bugs/
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>
>
>

Date2014-01-15 09:37
FromOeyvind Brandtsegg
SubjectRe: [Csnd] macro puzzle
Thanks for that,
now, I managed to distill the actually problematic macro.
The following expands differently in csound 5.13 and in csound5.19
Csound6 behaves the same as 5.19.
So, a change has been made that breaks old orchestras.





#define first(A)#
    $A    = 0.1
    print $A
#
#define second(A)#
    $first(iamp)
    i$A    = $A
    print i$A
#
    instr 1
$second(1)
    endin


i1 0 1
e






2014/1/14 jpff :
> The macrop exmansion takes place in the preprocessor and is textual.  The
> assignment to itest takes place at runtime; hence the results you see which
> are in my opiion correct.
>
> ==John
>
>
>
> On Tue, 14 Jan 2014, Oeyvind Brandtsegg wrote:
>
>> How is it that $A is interpreted both as 'itest' and as the value 1 in
>> the csd below?
>> it prints
>> SECTION 1:
>> new alloc for instr 1:
>> instr 1:  ithisitest = 1.000
>>
>>
>> 
>> 
>> 
>> 
>>
>> #define this(A)#
>>    ithis$A    = $A
>>    print ithis$A
>> #
>>    instr 1
>> itest = 1
>> $this(itest)
>>    endin
>>
>> 
>> 
>> i1 0 1
>> e
>> 
>> 
>>
>>
>>
>>
>> --
>>
>> Oeyvind Brandtsegg
>> Professor of Music Technology
>> NTNU
>> 7491 Trondheim
>> Norway
>> Cell: +47 92 203 205
>>
>> http://flyndresang.no/
>> http://www.partikkelaudio.com/
>> http://soundcloud.com/brandtsegg
>> http://soundcloud.com/t-emp
>>
>>
>> Send bugs reports to the Sourceforge bug trackers
>> csound6:
>>            https://sourceforge.net/p/csound/tickets/
>> csound5:
>>            https://sourceforge.net/p/csound/bugs/
>> Discussions of bugs and features can be posted here
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>> csound"
>>
>>
>>
>
>
> Send bugs reports to the Sourceforge bug trackers
> csound6:
>            https://sourceforge.net/p/csound/tickets/
> csound5:
>            https://sourceforge.net/p/csound/bugs/
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
> csound"
>
>



-- 

Oeyvind Brandtsegg
Professor of Music Technology
NTNU
7491 Trondheim
Norway
Cell: +47 92 203 205

http://flyndresang.no/
http://www.partikkelaudio.com/
http://soundcloud.com/brandtsegg
http://soundcloud.com/t-emp

Date2014-01-15 09:39
FromOeyvind Brandtsegg
SubjectRe: [Csnd] macro puzzle
... forgot to paste the console prints for the two different runs.
with csound5.13:
SECTION 1:
new alloc for instr 1:
instr 1:  iamp = 0.100
instr 1:  i1 = 1.000
B  0.000 ..  1.000 T  1.000 TT  1.000 M:      0.0
Score finished in csoundPerform().


with csound6
SECTION 1:
new alloc for instr 1:
instr 1:  iamp = 0.100
instr 1:  iiamp = 0.100
B  0.000 ..  1.000 T  1.000 TT  1.000 M:      0.0


* note the name change of the second printed variable

Oeyvind



2014/1/15 Oeyvind Brandtsegg :
> Thanks for that,
> now, I managed to distill the actually problematic macro.
> The following expands differently in csound 5.13 and in csound5.19
> Csound6 behaves the same as 5.19.
> So, a change has been made that breaks old orchestras.
>
> 
> 
> 
> 
> #define first(A)#
>     $A    = 0.1
>     print $A
> #
> #define second(A)#
>     $first(iamp)
>     i$A    = $A
>     print i$A
> #
>     instr 1
> $second(1)
>     endin
> 
> 
> i1 0 1
> e
> 
> 
>
>
>
>
> 2014/1/14 jpff :
>> The macrop exmansion takes place in the preprocessor and is textual.  The
>> assignment to itest takes place at runtime; hence the results you see which
>> are in my opiion correct.
>>
>> ==John
>>
>>
>>
>> On Tue, 14 Jan 2014, Oeyvind Brandtsegg wrote:
>>
>>> How is it that $A is interpreted both as 'itest' and as the value 1 in
>>> the csd below?
>>> it prints
>>> SECTION 1:
>>> new alloc for instr 1:
>>> instr 1:  ithisitest = 1.000
>>>
>>>
>>> 
>>> 
>>> 
>>> 
>>>
>>> #define this(A)#
>>>    ithis$A    = $A
>>>    print ithis$A
>>> #
>>>    instr 1
>>> itest = 1
>>> $this(itest)
>>>    endin
>>>
>>> 
>>> 
>>> i1 0 1
>>> e
>>> 
>>> 
>>>
>>>
>>>
>>>
>>> --
>>>
>>> Oeyvind Brandtsegg
>>> Professor of Music Technology
>>> NTNU
>>> 7491 Trondheim
>>> Norway
>>> Cell: +47 92 203 205
>>>
>>> http://flyndresang.no/
>>> http://www.partikkelaudio.com/
>>> http://soundcloud.com/brandtsegg
>>> http://soundcloud.com/t-emp
>>>
>>>
>>> Send bugs reports to the Sourceforge bug trackers
>>> csound6:
>>>            https://sourceforge.net/p/csound/tickets/
>>> csound5:
>>>            https://sourceforge.net/p/csound/bugs/
>>> Discussions of bugs and features can be posted here
>>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>>> csound"
>>>
>>>
>>>
>>
>>
>> Send bugs reports to the Sourceforge bug trackers
>> csound6:
>>            https://sourceforge.net/p/csound/tickets/
>> csound5:
>>            https://sourceforge.net/p/csound/bugs/
>> Discussions of bugs and features can be posted here
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>> csound"
>>
>>
>
>
>
> --
>
> Oeyvind Brandtsegg
> Professor of Music Technology
> NTNU
> 7491 Trondheim
> Norway
> Cell: +47 92 203 205
>
> http://flyndresang.no/
> http://www.partikkelaudio.com/
> http://soundcloud.com/brandtsegg
> http://soundcloud.com/t-emp



-- 

Oeyvind Brandtsegg
Professor of Music Technology
NTNU
7491 Trondheim
Norway
Cell: +47 92 203 205

http://flyndresang.no/
http://www.partikkelaudio.com/
http://soundcloud.com/brandtsegg
http://soundcloud.com/t-emp