Csound Csound-dev Csound-tekno Search About

[Cs-dev] string macro in score stopped working

Date2011-02-18 12:16
FromOeyvind Brandtsegg
Subject[Cs-dev] string macro in score stopped working
Hello

It seems using macro for replacement in a string in the score has
stopped working.
This used to work before:

#define scoreMac(N) #
i1 0 1 "Number$N"
#
$scoreMac(3)

in this case the string "Number3" should be used as p4,
instead, the string is now literally "Number$N".

This used to work earlier, I'm unsure of when it stopped working
(sometime during the last year perhaps)
If it's needed I will try to give a better estimate of when the error
might have occured.

Full test csd below, where I also implemented the same kind of string
replacement as a orchestra macro (and that works fine).
For me, running the example gives:
SECTION 1:
new alloc for instr 1:
Number$N
Number3
B  0.000 ..  1.000 T  1.000 TT  1.000 M:      0.0
Score finished in csoundPerform().

... where the first printed line is the score macro and the second
line is the orchestra macro

best
Oeyvind






	sr	=	44100
	ksmps	=	100

#define orcMac(N) #
Stest = "Number$N"
#

;********************************************
	instr 1

String1 strget p4
puts String1, 1

$orcMac(3)
puts Stest, 1

	endin
;********************************************



#define scoreMac(N) #
i1 0 1 "Number$N"
#
$scoreMac(3)

e



------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2011-02-18 14:40
Fromjpff@cs.bath.ac.uk
SubjectRe: [Cs-dev] string macro in score stopped working
I know exactly when this happened; it was a result of a request.

Issues are should macros be expanded in comments
Should macro be expanded in strings
Anywhere else that they should not nbe expanded/

The code exisys to do either -- it is a design issue.

Compare and contrast with C macros

==John ff

> Hello
>
> It seems using macro for replacement in a string in the score has
> stopped working.
> This used to work before:
>
> #define scoreMac(N) #
> i1 0 1 "Number$N"
> #
> $scoreMac(3)
>
> in this case the string "Number3" should be used as p4,
> instead, the string is now literally "Number$N".
>
> This used to work earlier, I'm unsure of when it stopped working
> (sometime during the last year perhaps)
> If it's needed I will try to give a better estimate of when the error
> might have occured.
>
> Full test csd below, where I also implemented the same kind of string
> replacement as a orchestra macro (and that works fine).
> For me, running the example gives:
> SECTION 1:
> new alloc for instr 1:
> Number$N
> Number3
> B  0.000 ..  1.000 T  1.000 TT  1.000 M:      0.0
> Score finished in csoundPerform().
>
> ... where the first printed line is the score macro and the second
> line is the orchestra macro
>
> best
> Oeyvind
>
> 
> 
> 
> 
>
> 	sr	=	44100
> 	ksmps	=	100
>
> #define orcMac(N) #
> Stest = "Number$N"
> #
>
> ;********************************************
> 	instr 1
>
> String1 strget p4
> puts String1, 1
>
> $orcMac(3)
> puts Stest, 1
>
> 	endin
> ;********************************************
> 
> 
>
> #define scoreMac(N) #
> i1 0 1 "Number$N"
> #
> $scoreMac(3)
>
> e
> 
> 
>
> ------------------------------------------------------------------------------
> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
> Pinpoint memory and threading errors before they happen.
> Find and fix more than 250 security defects in the development cycle.
> Locate bottlenecks in serial and parallel code that limit performance.
> http://p.sf.net/sfu/intel-dev2devfeb
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
>



------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2011-02-19 16:21
FromOeyvind Brandtsegg
SubjectRe: [Cs-dev] string macro in score stopped working
Hmm,
If the behaviour was changed deliberately, in a way that breaks
excisting orchestras, that would not be in line with our general
policy of always keeping backward compatibility.
I don't care so much if macros are expanded in comments or not (but I
guess I would expect them *not* to be expanded),
but I think macros should be expanded in strings,
and most importantly the behaviour should be the same for score and
orchesta macros.
Would it be possible to use a special character (backspace?) to
signify that special characters (like $) should be treated as string
literals?
That way we could have both options open.

best
Oeyvind

2011/2/18  :
> I know exactly when this happened; it was a result of a request.
>
> Issues are should macros be expanded in comments
> Should macro be expanded in strings
> Anywhere else that they should not nbe expanded/
>
> The code exisys to do either -- it is a design issue.
>
> Compare and contrast with C macros
>
> ==John ff
>
>> Hello
>>
>> It seems using macro for replacement in a string in the score has
>> stopped working.
>> This used to work before:
>>
>> #define scoreMac(N) #
>> i1 0 1 "Number$N"
>> #
>> $scoreMac(3)
>>
>> in this case the string "Number3" should be used as p4,
>> instead, the string is now literally "Number$N".
>>
>> This used to work earlier, I'm unsure of when it stopped working
>> (sometime during the last year perhaps)
>> If it's needed I will try to give a better estimate of when the error
>> might have occured.
>>
>> Full test csd below, where I also implemented the same kind of string
>> replacement as a orchestra macro (and that works fine).
>> For me, running the example gives:
>> SECTION 1:
>> new alloc for instr 1:
>> Number$N
>> Number3
>> B  0.000 ..  1.000 T  1.000 TT  1.000 M:      0.0
>> Score finished in csoundPerform().
>>
>> ... where the first printed line is the score macro and the second
>> line is the orchestra macro
>>
>> best
>> Oeyvind
>>
>> 
>> 
>> 
>> 
>>
>>       sr      =       44100
>>       ksmps   =       100
>>
>> #define orcMac(N) #
>> Stest = "Number$N"
>> #
>>
>> ;********************************************
>>       instr 1
>>
>> String1 strget p4
>> puts String1, 1
>>
>> $orcMac(3)
>> puts Stest, 1
>>
>>       endin
>> ;********************************************
>> 
>> 
>>
>> #define scoreMac(N) #
>> i1 0 1 "Number$N"
>> #
>> $scoreMac(3)
>>
>> e
>> 
>> 
>>
>> ------------------------------------------------------------------------------
>> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
>> Pinpoint memory and threading errors before they happen.
>> Find and fix more than 250 security defects in the development cycle.
>> Locate bottlenecks in serial and parallel code that limit performance.
>> http://p.sf.net/sfu/intel-dev2devfeb
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>>
>>
>
>
>
> ------------------------------------------------------------------------------
> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
> Pinpoint memory and threading errors before they happen.
> Find and fix more than 250 security defects in the development cycle.
> Locate bottlenecks in serial and parallel code that limit performance.
> http://p.sf.net/sfu/intel-dev2devfeb
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net