Csound Csound-dev Csound-tekno Search About

Immutable strings

Date2019-11-06 11:19
FromEduardo Moguillansky
SubjectImmutable strings
There are many opcodes which accept strings and derive some action from 
the string either at i-time, k-time or both. The channel opcodes come to 
mind as the most prominent ones. In some cases, the string is used at 
i-time to, for instance, find a pointer to a channel, decide upon some 
calculation, etc. It would be nice to be able to tell the opcode that 
this string will not mutate and that it is ok to set values at i-time, 
OR, to be able to indicate that the string can change during the 
lifetime of a note (if that makes sense for the given opcode).

I would like to propose that strings prepended with a given character, 
for instance ":" , would be treated as symbols (immutable strings) and 
an opcode could derive i-time actions from this. This would make opcodes 
like chnset able to react to changes in the channel name but still 
efficiently use the current implementation of setting the channel 
pointer at i-time, without the need to do a strcmp at each k-pass.

best regards,

Eduardo Moguillansky

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2019-11-06 18:46
FromRory Walsh
SubjectRe: Immutable strings
I agree that it would be nice to be able to do this, but I'm not sure I like the idea of prepending strings with a :  

On Wed, 6 Nov 2019 at 11:19, Eduardo Moguillansky <eduardo.moguillansky@gmail.com> wrote:
There are many opcodes which accept strings and derive some action from
the string either at i-time, k-time or both. The channel opcodes come to
mind as the most prominent ones. In some cases, the string is used at
i-time to, for instance, find a pointer to a channel, decide upon some
calculation, etc. It would be nice to be able to tell the opcode that
this string will not mutate and that it is ok to set values at i-time,
OR, to be able to indicate that the string can change during the
lifetime of a note (if that makes sense for the given opcode).

I would like to propose that strings prepended with a given character,
for instance ":" , would be treated as symbols (immutable strings) and
an opcode could derive i-time actions from this. This would make opcodes
like chnset able to react to changes in the channel name but still
efficiently use the current implementation of setting the channel
pointer at i-time, without the need to do a strcmp at each k-pass.

best regards,

Eduardo Moguillansky

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2019-11-06 18:49
FromDave Seidel
SubjectRe: Immutable strings
This syntax is used in Ruby, and perhaps other languages as well, so there's precedent.

On Wed, Nov 6, 2019 at 1:47 PM Rory Walsh <rorywalsh@ear.ie> wrote:
I agree that it would be nice to be able to do this, but I'm not sure I like the idea of prepending strings with a :  

On Wed, 6 Nov 2019 at 11:19, Eduardo Moguillansky <eduardo.moguillansky@gmail.com> wrote:
There are many opcodes which accept strings and derive some action from
the string either at i-time, k-time or both. The channel opcodes come to
mind as the most prominent ones. In some cases, the string is used at
i-time to, for instance, find a pointer to a channel, decide upon some
calculation, etc. It would be nice to be able to tell the opcode that
this string will not mutate and that it is ok to set values at i-time,
OR, to be able to indicate that the string can change during the
lifetime of a note (if that makes sense for the given opcode).

I would like to propose that strings prepended with a given character,
for instance ":" , would be treated as symbols (immutable strings) and
an opcode could derive i-time actions from this. This would make opcodes
like chnset able to react to changes in the channel name but still
efficiently use the current implementation of setting the channel
pointer at i-time, without the need to do a strcmp at each k-pass.

best regards,

Eduardo Moguillansky

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here


--
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2019-11-07 01:19
FromHlöðver Sigurðsson
SubjectRe: Immutable strings
Ruby is a good example of a language that isn't very backwards compatible. I like the idea presented here, I would welcome it. I wonder it there's a prettier way to notate this. With an opcode initImmuteableString? Or typehint/typemetadata
Sstring:i = ^immstr "channel1"

Don't know. But colon would be too non-explicit for my taste, idea presented here good! I'm a big fan of immutable data-structures.

On Wed, 6 Nov 2019 at 19:49, Dave Seidel <dave.seidel@gmail.com> wrote:
This syntax is used in Ruby, and perhaps other languages as well, so there's precedent.

On Wed, Nov 6, 2019 at 1:47 PM Rory Walsh <rorywalsh@ear.ie> wrote:
I agree that it would be nice to be able to do this, but I'm not sure I like the idea of prepending strings with a :  

On Wed, 6 Nov 2019 at 11:19, Eduardo Moguillansky <eduardo.moguillansky@gmail.com> wrote:
There are many opcodes which accept strings and derive some action from
the string either at i-time, k-time or both. The channel opcodes come to
mind as the most prominent ones. In some cases, the string is used at
i-time to, for instance, find a pointer to a channel, decide upon some
calculation, etc. It would be nice to be able to tell the opcode that
this string will not mutate and that it is ok to set values at i-time,
OR, to be able to indicate that the string can change during the
lifetime of a note (if that makes sense for the given opcode).

I would like to propose that strings prepended with a given character,
for instance ":" , would be treated as symbols (immutable strings) and
an opcode could derive i-time actions from this. This would make opcodes
like chnset able to react to changes in the channel name but still
efficiently use the current implementation of setting the channel
pointer at i-time, without the need to do a strcmp at each k-pass.

best regards,

Eduardo Moguillansky

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here


--
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2019-11-07 09:01
FromEduardo Moguillansky
SubjectRe: Immutable strings

To be clear, this proposes more a convention than a modification of the current state. Strings are implemented in a very simple way which makes modern opcodes which deal with strings rather inefficient. In many cases such strings are not meant to change during the lifetime of a note and in fact many opcodes assume that they don't. Since it is not possible to indicate with the type that a string is immutable, it would need a special opcode to accomodate for mutable strings, or, the opcode would need to check at each k-cycle if the string has changed. This proposal would allow the user to communicate if a certain string can mutate or not and thus allow an opcode to react to this by simple checking the first char of the strings value. It would allow for further optimizations, like interning, etc.

On 07.11.19 02:19, Hlöðver Sigurðsson wrote:
Ruby is a good example of a language that isn't very backwards compatible. I like the idea presented here, I would welcome it. I wonder it there's a prettier way to notate this. With an opcode initImmuteableString? Or typehint/typemetadata
Sstring:i = ^immstr "channel1"

Don't know. But colon would be too non-explicit for my taste, idea presented here good! I'm a big fan of immutable data-structures.

On Wed, 6 Nov 2019 at 19:49, Dave Seidel <dave.seidel@gmail.com> wrote:
This syntax is used in Ruby, and perhaps other languages as well, so there's precedent.

On Wed, Nov 6, 2019 at 1:47 PM Rory Walsh <rorywalsh@ear.ie> wrote:
I agree that it would be nice to be able to do this, but I'm not sure I like the idea of prepending strings with a :  

On Wed, 6 Nov 2019 at 11:19, Eduardo Moguillansky <eduardo.moguillansky@gmail.com> wrote:
There are many opcodes which accept strings and derive some action from
the string either at i-time, k-time or both. The channel opcodes come to
mind as the most prominent ones. In some cases, the string is used at
i-time to, for instance, find a pointer to a channel, decide upon some
calculation, etc. It would be nice to be able to tell the opcode that
this string will not mutate and that it is ok to set values at i-time,
OR, to be able to indicate that the string can change during the
lifetime of a note (if that makes sense for the given opcode).

I would like to propose that strings prepended with a given character,
for instance ":" , would be treated as symbols (immutable strings) and
an opcode could derive i-time actions from this. This would make opcodes
like chnset able to react to changes in the channel name but still
efficiently use the current implementation of setting the channel
pointer at i-time, without the need to do a strcmp at each k-pass.

best regards,

Eduardo Moguillansky

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here


--
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2019-11-07 10:35
FromRory Walsh
SubjectRe: Immutable strings
Yes, and the proposal would then allow for opcodes to work better with strings in the future. As I said earlier, I think the idea is good, but I just don't like the ':' prefix. I'm but one voice among many. 

On Thu, 7 Nov 2019 at 09:02, Eduardo Moguillansky <eduardo.moguillansky@gmail.com> wrote:

To be clear, this proposes more a convention than a modification of the current state. Strings are implemented in a very simple way which makes modern opcodes which deal with strings rather inefficient. In many cases such strings are not meant to change during the lifetime of a note and in fact many opcodes assume that they don't. Since it is not possible to indicate with the type that a string is immutable, it would need a special opcode to accomodate for mutable strings, or, the opcode would need to check at each k-cycle if the string has changed. This proposal would allow the user to communicate if a certain string can mutate or not and thus allow an opcode to react to this by simple checking the first char of the strings value. It would allow for further optimizations, like interning, etc.

On 07.11.19 02:19, Hlöðver Sigurðsson wrote:
Ruby is a good example of a language that isn't very backwards compatible. I like the idea presented here, I would welcome it. I wonder it there's a prettier way to notate this. With an opcode initImmuteableString? Or typehint/typemetadata
Sstring:i = ^immstr "channel1"

Don't know. But colon would be too non-explicit for my taste, idea presented here good! I'm a big fan of immutable data-structures.

On Wed, 6 Nov 2019 at 19:49, Dave Seidel <dave.seidel@gmail.com> wrote:
This syntax is used in Ruby, and perhaps other languages as well, so there's precedent.

On Wed, Nov 6, 2019 at 1:47 PM Rory Walsh <rorywalsh@ear.ie> wrote:
I agree that it would be nice to be able to do this, but I'm not sure I like the idea of prepending strings with a :  

On Wed, 6 Nov 2019 at 11:19, Eduardo Moguillansky <eduardo.moguillansky@gmail.com> wrote:
There are many opcodes which accept strings and derive some action from
the string either at i-time, k-time or both. The channel opcodes come to
mind as the most prominent ones. In some cases, the string is used at
i-time to, for instance, find a pointer to a channel, decide upon some
calculation, etc. It would be nice to be able to tell the opcode that
this string will not mutate and that it is ok to set values at i-time,
OR, to be able to indicate that the string can change during the
lifetime of a note (if that makes sense for the given opcode).

I would like to propose that strings prepended with a given character,
for instance ":" , would be treated as symbols (immutable strings) and
an opcode could derive i-time actions from this. This would make opcodes
like chnset able to react to changes in the channel name but still
efficiently use the current implementation of setting the channel
pointer at i-time, without the need to do a strcmp at each k-pass.

best regards,

Eduardo Moguillansky

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here


--
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2019-11-07 11:15
FromHlöðver Sigurðsson
SubjectRe: Immutable strings
The word immuteable also doesnt seem to fit this description well, since one can reassign a new value on new instance, which is for example not always the case with a rate variables, which means that memory is freed for new data, instead of deriving new data as a transaction of old and new value. As terminology, it would fit better to call it constant with enhanced memory properties, and traditional i rate values just a variable, just like in javascript, but js const vs var has tough more to do with object re-referencing.

If doing this is important for strings, then why not plan something long term for homogenic syntax on other variable types like i numbers and i tables?

On Thu, 7 Nov 2019 at 11:35, Rory Walsh <rorywalsh@ear.ie> wrote:
Yes, and the proposal would then allow for opcodes to work better with strings in the future. As I said earlier, I think the idea is good, but I just don't like the ':' prefix. I'm but one voice among many. 

On Thu, 7 Nov 2019 at 09:02, Eduardo Moguillansky <eduardo.moguillansky@gmail.com> wrote:

To be clear, this proposes more a convention than a modification of the current state. Strings are implemented in a very simple way which makes modern opcodes which deal with strings rather inefficient. In many cases such strings are not meant to change during the lifetime of a note and in fact many opcodes assume that they don't. Since it is not possible to indicate with the type that a string is immutable, it would need a special opcode to accomodate for mutable strings, or, the opcode would need to check at each k-cycle if the string has changed. This proposal would allow the user to communicate if a certain string can mutate or not and thus allow an opcode to react to this by simple checking the first char of the strings value. It would allow for further optimizations, like interning, etc.

On 07.11.19 02:19, Hlöðver Sigurðsson wrote:
Ruby is a good example of a language that isn't very backwards compatible. I like the idea presented here, I would welcome it. I wonder it there's a prettier way to notate this. With an opcode initImmuteableString? Or typehint/typemetadata
Sstring:i = ^immstr "channel1"

Don't know. But colon would be too non-explicit for my taste, idea presented here good! I'm a big fan of immutable data-structures.

On Wed, 6 Nov 2019 at 19:49, Dave Seidel <dave.seidel@gmail.com> wrote:
This syntax is used in Ruby, and perhaps other languages as well, so there's precedent.

On Wed, Nov 6, 2019 at 1:47 PM Rory Walsh <rorywalsh@ear.ie> wrote:
I agree that it would be nice to be able to do this, but I'm not sure I like the idea of prepending strings with a :  

On Wed, 6 Nov 2019 at 11:19, Eduardo Moguillansky <eduardo.moguillansky@gmail.com> wrote:
There are many opcodes which accept strings and derive some action from
the string either at i-time, k-time or both. The channel opcodes come to
mind as the most prominent ones. In some cases, the string is used at
i-time to, for instance, find a pointer to a channel, decide upon some
calculation, etc. It would be nice to be able to tell the opcode that
this string will not mutate and that it is ok to set values at i-time,
OR, to be able to indicate that the string can change during the
lifetime of a note (if that makes sense for the given opcode).

I would like to propose that strings prepended with a given character,
for instance ":" , would be treated as symbols (immutable strings) and
an opcode could derive i-time actions from this. This would make opcodes
like chnset able to react to changes in the channel name but still
efficiently use the current implementation of setting the channel
pointer at i-time, without the need to do a strcmp at each k-pass.

best regards,

Eduardo Moguillansky

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here


--
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2019-11-07 12:20
FromJohn ff
SubjectRe: Immutable strings
So you expect someone to change every opcode that accepts a string as input?

Is it worth it?

⁣Sent from TypeApp ​

On Nov 7, 2019, 09:02, at 09:02, Eduardo Moguillansky  wrote:
>To be clear, this proposes more a convention than a modification of the
>
>current state. Strings are implemented in a very simple way which makes
>
>modern opcodes which deal with strings rather inefficient. In many
>cases 
>such strings are not meant to change during the lifetime of a note and 
>in fact many opcodes assume that they don't. Since it is not possible
>to 
>indicate with the type that a string is immutable, it would need a 
>special opcode to accomodate for mutable strings, or, the opcode would 
>need to check at each k-cycle if the string has changed. This proposal 
>would allow the user to communicate if a certain string can mutate or 
>not and thus allow an opcode to react to this by simple checking the 
>first char of the strings value. It would allow for further 
>optimizations, like interning, etc.
>
>On 07.11.19 02:19, Hlöðver Sigurðsson wrote:
>> Ruby is a good example of a language that isn't very backwards 
>> compatible. I like the idea presented here, I would welcome it. I 
>> wonder it there's a prettier way to notate this. With an opcode 
>> initImmuteableString? Or typehint/typemetadata
>> Sstring:i = ^immstr "channel1"
>>
>> Don't know. But colon would be too non-explicit for my taste, idea 
>> presented here good! I'm a big fan of immutable data-structures.
>>
>> On Wed, 6 Nov 2019 at 19:49, Dave Seidel > > wrote:
>>
>>     This syntax is used in Ruby, and perhaps other languages as well,
>>     so there's precedent.
>>
>>     On Wed, Nov 6, 2019 at 1:47 PM Rory Walsh >     > wrote:
>>
>>         I agree that it would be nice to be able to do this, but I'm
>>         not sure I like the idea of prepending strings with a :
>>
>>         On Wed, 6 Nov 2019 at 11:19, Eduardo Moguillansky
>>         >         > wrote:
>>
>>             There are many opcodes which accept strings and derive
>>             some action from
>>             the string either at i-time, k-time or both. The channel
>>             opcodes come to
>>             mind as the most prominent ones. In some cases, the
>string
>>             is used at
>>             i-time to, for instance, find a pointer to a channel,
>>             decide upon some
>>             calculation, etc. It would be nice to be able to tell the
>>             opcode that
>>             this string will not mutate and that it is ok to set
>>             values at i-time,
>>             OR, to be able to indicate that the string can change
>>             during the
>>             lifetime of a note (if that makes sense for the given
>opcode).
>>
>>             I would like to propose that strings prepended with a
>>             given character,
>>             for instance ":" , would be treated as symbols (immutable
>>             strings) and
>>             an opcode could derive i-time actions from this. This
>>             would make opcodes
>>             like chnset able to react to changes in the channel name
>>             but still
>>             efficiently use the current implementation of setting the
>>             channel
>>             pointer at i-time, without the need to do a strcmp at
>each
>>             k-pass.
>>
>>             best regards,
>>
>>             Eduardo Moguillansky
>>
>>             Csound mailing list
>>             Csound@listserv.heanet.ie
>
>>             https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>>             Send bugs reports to
>>             https://github.com/csound/csound/issues
>>             Discussions of bugs and features can be posted here
>>
>>         Csound mailing list Csound@listserv.heanet.ie
>>         
>>         https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs
>>         reports to https://github.com/csound/csound/issues
>Discussions
>>         of bugs and features can be posted here 
>>
>>
>>
>>     -- 
>>     http://mysterybear.net
>>     https://soundcloud.com/mysterybear
>>     https://mysterybear.bandcamp.com
>>     https://www.youtube.com/channel/UCo0--3uN5ycq_aupZXskBgA
>>
>>     http://recordings.irritablehedgehog.com/album/dave-seidel-60-hz
>>     Csound mailing list Csound@listserv.heanet.ie
>>     
>>     https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports
>>     to https://github.com/csound/csound/issues Discussions of bugs
>and
>>     features can be posted here 
>>
>> Csound mailing list Csound@listserv.heanet.ie 
>>  
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to 
>> https://github.com/csound/csound/issues Discussions of bugs and 
>> features can be posted here 
>
>Csound mailing list
>Csound@listserv.heanet.ie
>https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>Send bugs reports to
>        https://github.com/csound/csound/issues
>Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2019-11-07 13:37
FromEduardo Moguillansky
SubjectRe: Immutable strings
No, it CAN be used by an opcode developer to decide what kind of 
behaviour is expected. It would make sense in opcodes like chnget and 
chnset which don't accept the name of the channel to change during the 
lifetime of a note. So instead of having to create something like 
chngetk one could specify the expected behaviour by, for example, 
prepending the channel name with a given prefix.

On 07.11.19 13:20, John ff wrote:
> So you expect someone to change every opcode that accepts a string as input?
>
> Is it worth it?
>
> ⁣Sent from TypeApp ​
>
> On Nov 7, 2019, 09:02, at 09:02, Eduardo Moguillansky  wrote:
>> To be clear, this proposes more a convention than a modification of the
>>
>> current state. Strings are implemented in a very simple way which makes
>>
>> modern opcodes which deal with strings rather inefficient. In many
>> cases
>> such strings are not meant to change during the lifetime of a note and
>> in fact many opcodes assume that they don't. Since it is not possible
>> to
>> indicate with the type that a string is immutable, it would need a
>> special opcode to accomodate for mutable strings, or, the opcode would
>> need to check at each k-cycle if the string has changed. This proposal
>> would allow the user to communicate if a certain string can mutate or
>> not and thus allow an opcode to react to this by simple checking the
>> first char of the strings value. It would allow for further
>> optimizations, like interning, etc.
>>
>> On 07.11.19 02:19, Hlöðver Sigurðsson wrote:
>>> Ruby is a good example of a language that isn't very backwards
>>> compatible. I like the idea presented here, I would welcome it. I
>>> wonder it there's a prettier way to notate this. With an opcode
>>> initImmuteableString? Or typehint/typemetadata
>>> Sstring:i = ^immstr "channel1"
>>>
>>> Don't know. But colon would be too non-explicit for my taste, idea
>>> presented here good! I'm a big fan of immutable data-structures.
>>>
>>> On Wed, 6 Nov 2019 at 19:49, Dave Seidel >> > wrote:
>>>
>>>      This syntax is used in Ruby, and perhaps other languages as well,
>>>      so there's precedent.
>>>
>>>      On Wed, Nov 6, 2019 at 1:47 PM Rory Walsh >>      > wrote:
>>>
>>>          I agree that it would be nice to be able to do this, but I'm
>>>          not sure I like the idea of prepending strings with a :
>>>
>>>          On Wed, 6 Nov 2019 at 11:19, Eduardo Moguillansky
>>>          >>          > wrote:
>>>
>>>              There are many opcodes which accept strings and derive
>>>              some action from
>>>              the string either at i-time, k-time or both. The channel
>>>              opcodes come to
>>>              mind as the most prominent ones. In some cases, the
>> string
>>>              is used at
>>>              i-time to, for instance, find a pointer to a channel,
>>>              decide upon some
>>>              calculation, etc. It would be nice to be able to tell the
>>>              opcode that
>>>              this string will not mutate and that it is ok to set
>>>              values at i-time,
>>>              OR, to be able to indicate that the string can change
>>>              during the
>>>              lifetime of a note (if that makes sense for the given
>> opcode).
>>>              I would like to propose that strings prepended with a
>>>              given character,
>>>              for instance ":" , would be treated as symbols (immutable
>>>              strings) and
>>>              an opcode could derive i-time actions from this. This
>>>              would make opcodes
>>>              like chnset able to react to changes in the channel name
>>>              but still
>>>              efficiently use the current implementation of setting the
>>>              channel
>>>              pointer at i-time, without the need to do a strcmp at
>> each
>>>              k-pass.
>>>
>>>              best regards,
>>>
>>>              Eduardo Moguillansky
>>>
>>>              Csound mailing list
>>>              Csound@listserv.heanet.ie
>> 
>>>              https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>>>              Send bugs reports to
>>>              https://github.com/csound/csound/issues
>>>              Discussions of bugs and features can be posted here
>>>
>>>          Csound mailing list Csound@listserv.heanet.ie
>>>          
>>>          https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs
>>>          reports to https://github.com/csound/csound/issues
>> Discussions
>>>          of bugs and features can be posted here
>>>
>>>
>>>
>>>      --
>>>      http://mysterybear.net
>>>      https://soundcloud.com/mysterybear
>>>      https://mysterybear.bandcamp.com
>>>      https://www.youtube.com/channel/UCo0--3uN5ycq_aupZXskBgA
>>>
>>>      http://recordings.irritablehedgehog.com/album/dave-seidel-60-hz
>>>      Csound mailing list Csound@listserv.heanet.ie
>>>      
>>>      https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports
>>>      to https://github.com/csound/csound/issues Discussions of bugs
>> and
>>>      features can be posted here
>>>
>>> Csound mailing list Csound@listserv.heanet.ie
>>> 
>>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
>>> https://github.com/csound/csound/issues Discussions of bugs and
>>> features can be posted here
>> Csound mailing list
>> Csound@listserv.heanet.ie
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>> Send bugs reports to
>>         https://github.com/csound/csound/issues
>> Discussions of bugs and features can be posted here
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>          https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2019-11-07 14:01
FromSteven Yi
SubjectRe: Immutable strings
I am not in favor of this proposed change as I think it is trying to solve the problem using a bad convention. I think this kind of approach to reuse existing mechanisms rather than introduce new ones is what made the Csound5->6 transition so onerous and makes the system harder to maintain. I would suspect any convention of "if first letter" will end up being a burden to both internal maintenance in the future and complicate tooling support in the ecosystem.

Additionally, this doesn't scale to other data types.  If we want to express an idea of const-ness to other data, this doesn't work.

As it is today, we have the option to declare multiple opcodes with variations in name that permits different processing to happen. If we want something like const, I don't think any special convention should be introduced.

I discussed a bit of this in my PhD thesis about the problems of rate in Csound and how it was not taken into account past the original i, k, and a types.  w and f have their own rates, S does not have a rate associated with it,  and none of those have a concept of init-time vs per-time. This made it an open question as to how to approach it really for user-defined types. I think it's easier not to consider rates as much moving forward as being a part of the data type but rather a byproduct of the opcodes which are doing the processing.




On Wed, Nov 6, 2019 at 6:19 AM Eduardo Moguillansky <eduardo.moguillansky@gmail.com> wrote:
There are many opcodes which accept strings and derive some action from
the string either at i-time, k-time or both. The channel opcodes come to
mind as the most prominent ones. In some cases, the string is used at
i-time to, for instance, find a pointer to a channel, decide upon some
calculation, etc. It would be nice to be able to tell the opcode that
this string will not mutate and that it is ok to set values at i-time,
OR, to be able to indicate that the string can change during the
lifetime of a note (if that makes sense for the given opcode).

I would like to propose that strings prepended with a given character,
for instance ":" , would be treated as symbols (immutable strings) and
an opcode could derive i-time actions from this. This would make opcodes
like chnset able to react to changes in the channel name but still
efficiently use the current implementation of setting the channel
pointer at i-time, without the need to do a strcmp at each k-pass.

best regards,

Eduardo Moguillansky

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here