| We could do it as part of the parser, perhaps when we're walking the
parse tree. I guess compilers in general do issue warnings for coding
patterns, so it might make sense. It just feels odd as it's a very
specific scenario for a single opcode.
Anyways, if we do this, we should probably create a generic
checkForWarnings() kind of function that would then do the check. We
could then extend what checks we do. We could then add flags,
similarly to how gcc has -Wall, -Wno-some-option, -Wno-deprecated,
etc. That'd give some control then to users to turn off certain
warning types.
What I wouldn't like is just some code to be hacked in, and would
prefer a framework for warnings to be done.
On Fri, Apr 4, 2014 at 8:45 AM, Oeyvind Brandtsegg
wrote:
> Just to note, if by the original code you mean the example I sent, it
> was a simplified test just to show the problem.
> The reinit was needed in the actual code where I discovered the problem.
>
> Wouldn't it be ok to catch the k-rate expression inside i() at the
> preprocessing stage?
>
> Oeyvind
>
> 2014-04-04 14:37 GMT+02:00 Steven Yi :
>> I don't think it should be sum.i, as the compiler detects correctly
>> that the expression being used is a k-rate one. The original code
>> could have been re-written as:
>>
>> i2 = i(kswitch) + 1
>>
>> which would have worked fine.
>>
>> I think though that the original code could probably be modified to be
>> a bit simpler. It's not clear why there's a re-init being used, and
>> if there isn't a better way to go about it.
>>
>> On Fri, Apr 4, 2014 at 8:32 AM, Victor Lazzarini
>> wrote:
>>> Shouldn't it be sum.i then?
>>> ========================
>>> Dr Victor Lazzarini
>>> Senior Lecturer
>>> NUI Maynooth, Ireland
>>> victor dot lazzarini at nuim dot ie
>>>
>>>
>>>
>>>
>>> On 4 Apr 2014, at 13:22, Steven Yi wrote:
>>>
>>>> I think this might be sort of a hack to detect. What happens is that the line:
>>>>
>>>> i2 = i(kswitch+1)
>>>>
>>>> becomes something like:
>>>>
>>>> #k0 sum.k kswitch, 1
>>>> i2 = i(#k0)
>>>>
>>>> with the sum happening at perf-time, and #k0 being initialized to 0.
>>>> The sum would not do anything a init-time, so #k0 just remains 0 when
>>>> the i() goes to compute.
>>>>
>>>>
>>>>
>>>> On Fri, Apr 4, 2014 at 8:17 AM, Victor Lazzarini
>>>> wrote:
>>>>> Agreed that is an easy mistake and it should be protected somehow, but not sure how to tackle it
>>>>> right now. It would need to be made an exception in the parser.
>>>>> ========================
>>>>> Dr Victor Lazzarini
>>>>> Senior Lecturer
>>>>> NUI Maynooth, Ireland
>>>>> victor dot lazzarini at nuim dot ie
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On 4 Apr 2014, at 12:24, Oeyvind Brandtsegg wrote:
>>>>>
>>>>>> I see,
>>>>>> it is an easy mistake to make though.
>>>>>> I see now that it is noted in the manual,
>>>>>> but still, if one is not looking in the manual one could expect my
>>>>>> original code to work.
>>>>>> Could we make k-rate expressions illegal in this case, since it
>>>>>> otherwise can lead to unexpected results. If the parser would stop and
>>>>>> give an error message that k-rate expressions must be done outside the
>>>>>> i(.), I think it would be very helpful.
>>>>>> Oeyvind
>>>>>>
>>>>>> 2014-04-04 13:17 GMT+02:00 Victor Lazzarini :
>>>>>>> it's because in i(.) the . has to be a variable (which is actually a memory address).
>>>>>>> ========================
>>>>>>> Dr Victor Lazzarini
>>>>>>> Senior Lecturer
>>>>>>> NUI Maynooth, Ireland
>>>>>>> victor dot lazzarini at nuim dot ie
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On 4 Apr 2014, at 10:24, Oeyvind Brandtsegg wrote:
>>>>>>>
>>>>>>>> I wonder if this is a bug,
>>>>>>>> I would expect i2 and i3 to be equal in the following example, but they are not.
>>>>>>>> Almost as if i(kswitch+1) reads the *previous i-time value* of kswitch
>>>>>>>> somehow (??)
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> sr = 44100
>>>>>>>> kr = 441
>>>>>>>> ksmps = 100
>>>>>>>> nchnls = 2
>>>>>>>>
>>>>>>>> instr 1
>>>>>>>>
>>>>>>>> kmetro metro 1
>>>>>>>> kswitch init 0
>>>>>>>> kswitch = (kswitch+kmetro)%2
>>>>>>>> printk2 kswitch
>>>>>>>> if kmetro > 0 then
>>>>>>>> reinit testme
>>>>>>>> endif
>>>>>>>>
>>>>>>>> testme:
>>>>>>>> i1 = i(kswitch)
>>>>>>>> i2 = i(kswitch+1)
>>>>>>>> i3 = i1+1
>>>>>>>> print i1, i2, i3
>>>>>>>> rireturn
>>>>>>>>
>>>>>>>> endin
>>>>>>>>
>>>>>>>>
>>>>>>>> i1 0 5
>>>>>>>> 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
>>>>>>>>
>>>>>>>> ------------------------------------------------------------------------------
>>>>>>>> _______________________________________________
>>>>>>>> Csound-devel mailing list
>>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>>
>>>>>>>
>>>>>>> ------------------------------------------------------------------------------
>>>>>>> _______________________________________________
>>>>>>> Csound-devel mailing list
>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>>
>>>>>> 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
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> _______________________________________________
>>>>>> Csound-devel mailing list
>>>>>> Csound-devel@lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> _______________________________________________
>>>>> Csound-devel mailing list
>>>>> Csound-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>
>>>> ------------------------------------------------------------------------------
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
>
> --
>
> 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
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net |