\context foo = "bar" vs. \new foo

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

\context foo = "bar" vs. \new foo

Graham Percival-2
Why do we have \context and \new ?  I know that \context lets you name
a context and \new doesn't... but is that the only difference?  ...
actually, you can use \context to do fancy stuff with already-existing
contexts, right?

Could we change \new so that it can also name a new context?  I'm
looking at the vocal templates, having:
\score {
   \new Staff { \violinmelody }
   \context Staff =singer {
     \context Voice = vocal { \blah }
   \new PianoStaff {...}
}

The alternating \new and \context seems confusing.  It would be nice if
we could do
   \new Staff { \violinmelody }
   \new Staff = singer {
     \new Voice = vocal { \blah }
   \new PianoStaff {...}

Cheers,
- Graham



_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: \context foo = "bar" vs. \new foo

Mats Bengtsson-4
The difference is that \new internally generates a unique new
name to the context, thus making sure that you really get a new
context. If you use \context, then you must make up a new unique
name yourself, if you want to get a new context and not just
another invocation of some existing context.

It wouldn't make sense to let a user specify a context name
with \new, since then there is no longer any guarantee that
the context really is new, right? Also, if you want to name a
context, then you should use \context.

   /Mats

Graham Percival wrote:

> Why do we have \context and \new ?  I know that \context lets you name
> a context and \new doesn't... but is that the only difference?  ...
> actually, you can use \context to do fancy stuff with already-existing
> contexts, right?
>
> Could we change \new so that it can also name a new context?  I'm
> looking at the vocal templates, having:
> \score {
>   \new Staff { \violinmelody }
>   \context Staff =singer {
>     \context Voice = vocal { \blah }
>   \new PianoStaff {...}
> }
>
> The alternating \new and \context seems confusing.  It would be nice
> if we could do
>   \new Staff { \violinmelody }
>   \new Staff = singer {
>     \new Voice = vocal { \blah }
>   \new PianoStaff {...}
>
> Cheers,
> - Graham
>
>
>
> _______________________________________________
> lilypond-devel mailing list
> [hidden email]
> http://lists.gnu.org/mailman/listinfo/lilypond-devel



--
=============================================
        Mats Bengtsson
        Signal Processing
        Signals, Sensors and Systems
        Royal Institute of Technology
        SE-100 44  STOCKHOLM
        Sweden
        Phone: (+46) 8 790 8463
        Fax:   (+46) 8 790 7260
        Email: [hidden email]
        WWW: http://www.s3.kth.se/~mabe
=============================================



_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: \context foo = "bar" vs. \new foo

Don Blaheta
Quoth Mats Bengtsson:
> It wouldn't make sense to let a user specify a context name
> with \new, since then there is no longer any guarantee that
> the context really is new, right? Also, if you want to name a
> context, then you should use \context.

Would it make sense to permit \new Foo = "bar", but have it be an error
if a "bar" context already existed?  I think that would actually help
someone get a good handle on exactly what contexts they're creating, as
opposed to which ones they are re-entering for whatever reason.  It
would also help you catch when you accidentally reuse a name.

I'm not proposing that \context Foo = "bar" *couldn't* create a new
context, though, as I don't think there's any error-checking benefit to
that and it would break all the old files.

--
-=-Don Blaheta-=-=-[hidden email]-=-=-=-<http://www.blahedo.org/>-=-
The more things change, the more they stay insane.


_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: \context foo = "bar" vs. \new foo

Han-Wen Nienhuys
Don Blaheta wrote:

> Quoth Mats Bengtsson:
>
>>It wouldn't make sense to let a user specify a context name
>>with \new, since then there is no longer any guarantee that
>>the context really is new, right? Also, if you want to name a
>>context, then you should use \context.
>
>
> Would it make sense to permit \new Foo = "bar", but have it be an error
> if a "bar" context already existed?  I think that would actually help

I think that's a good idea . I agree with Graham that mixing \new and
\context looks a bit odd.


--
  Han-Wen Nienhuys - [hidden email] - http://www.xs4all.nl/~hanwen


_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: \context foo = "bar" vs. \new foo

Trevor Bača-2
In reply to this post by Graham Percival-2
On 2/10/06, Graham Percival <[hidden email]> wrote:

> Why do we have \context and \new ?  I know that \context lets you name
> a context and \new doesn't... but is that the only difference?  ...
> actually, you can use \context to do fancy stuff with already-existing
> contexts, right?
>
> Could we change \new so that it can also name a new context?  I'm
> looking at the vocal templates, having:
> \score {
>    \new Staff { \violinmelody }
>    \context Staff =singer {
>      \context Voice = vocal { \blah }
>    \new PianoStaff {...}
> }
>
> The alternating \new and \context seems confusing.  It would be nice if
> we could do
>    \new Staff { \violinmelody }
>    \new Staff = singer {
>      \new Voice = vocal { \blah }
>    \new PianoStaff {...}
Ah ... you know, I remember being surprisingly confused by just this
point way back when I was first studying the templates, but had since
forgotten the point.

Certainly would be cleaner, if there's a reasonable implementation path.

--
Trevor Bača
[hidden email]

_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: \context foo = "bar" vs. \new foo

Erik Sandberg
In reply to this post by Don Blaheta
On Friday 10 February 2006 21.47, Don Blaheta wrote:

> Quoth Mats Bengtsson:
> > It wouldn't make sense to let a user specify a context name
> > with \new, since then there is no longer any guarantee that
> > the context really is new, right? Also, if you want to name a
> > context, then you should use \context.
>
> Would it make sense to permit \new Foo = "bar", but have it be an error
> if a "bar" context already existed?  I think that would actually help
> someone get a good handle on exactly what contexts they're creating, as
> opposed to which ones they are re-entering for whatever reason.  It
> would also help you catch when you accidentally reuse a name.

> I'm not proposing that \context Foo = "bar" *couldn't* create a new
> context, though, as I don't think there's any error-checking benefit to
> that and it would break all the old files.

Maybe \context could be renamed to something else, such as \addto Staff=bar,
since its primary use will be to append music to an existing context. The
word "context" might sound scary/technical to a beginner.

There is a small problem with introducing the syntax \new Foo=bar: it
introduces another variable-number-of-arguments command to the grammar. I
guess it's not a big problem though, since Han-Wen seems to like the idea.

--
Erik


_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: \context foo = "bar" vs. \new foo

Graham Percival-2

On 11-Feb-06, at 2:49 AM, Erik Sandberg wrote:

> On Friday 10 February 2006 21.47, Don Blaheta wrote:
>> Would it make sense to permit \new Foo = "bar", but have it be an
>> error
>> if a "bar" context already existed?

That's exactly what I'm hoping for.  :)

>> I'm not proposing that \context Foo = "bar" *couldn't* create a new
>> context, though, as I don't think there's any error-checking benefit
>> to
>> that and it would break all the old files.

Again, exactly.

> Maybe \context could be renamed to something else, such as \addto
> Staff=bar,
> since its primary use will be to append music to an existing context.
> The
> word "context" might sound scary/technical to a beginner.

How much do beginners need to use \context, though?  (if we allow \new
Voice="alto")
(this question is aimed at vocal music, since I've only used \context
*once* in all my string writing, that that was a pretty weird case)
Right now beginners need to use \context for vocal voices, and can
either use \context or \new for all the other stuff.  If we allow \new
Voice="alto", then AFAIK beginners can use \new for everything.  
\context would only be used for playing fancy games with stuff.

If we keep \context as it is, we avoid adding another rule to
convert-ly and getting accused of breaking backwards compatibility
again.  :)
(particularly since convert-ly won't know if a \context should be
turned into \new or \addto)

Cheers,
- Graham



_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: \context foo = "bar" vs. \new foo

Han-Wen Nienhuys
Graham Percival wrote:
>>> Would it make sense to permit \new Foo = "bar", but have it be an error
>>> if a "bar" context already existed?
>
>
> That's exactly what I'm hoping for.  :)

I haven't done this because it's extra work, but

   \new Foo = "bar"

will always create new context, and will name it "bar", so you can refer
to it later with

   \context Foo=bar

I'm not sure if \addto is a right substitute for \context, as it looks
confusingly similar to \addlyrics and \lyricsto, which are mostly
unrelated to \context.

>>> I'm not proposing that \context Foo = "bar" *couldn't* create a new
>>> context, though, as I don't think there's any error-checking benefit to
>>> that and it would break all the old files.

I'm all for it, but we should postpone this change for lilypond 3.0,
where we will have ample opportunity to break old files :-)

> How much do beginners need to use \context, though?  (if we allow \new
> Voice="alto")

Almost none.

--
  Han-Wen Nienhuys - [hidden email] - http://www.xs4all.nl/~hanwen


_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel