# Formal argument cannot be a constant

**URL:** <https://in-thread.sonic-pi.net/t/formal-argument-cannot-be-a-constant/7035>\
**Category:** Support, Help & Resources\
**Created:** [August 25, 2022, 5:54pm UTC](https://in-thread.sonic-pi.net/t/formal-argument-cannot-be-a-constant/7035 "2022-08-25T17:54:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Buce](https://avatars.discourse-cdn.com/v4/letter/b/e5b9ba/32.png) [@Buce](https://in-thread.sonic-pi.net/u/Buce)\
**Post date:** [August 25, 2022, 5:54pm UTC](https://in-thread.sonic-pi.net/t/formal-argument-cannot-be-a-constant/7035/1 "2022-08-25T17:54:16Z")

</div>

Hello …

**Constants start with an uppercase letter in ruby**.

This is a [ruby](https://www.ruby-forum.com/t/formal-argument-cannot-be-a-constant/216505) carry over but I did not know about it.

It seems not so common in some other programming languages I know.  
Especially for parameter/argument names it seems to me an  
unexpected underlying syntactical restriction.

In some typed languages (e.g. c,c++,c# ) I can meaningfully  
restrict parameters to be constant.

It also seems not to be mentioned in SP help system explicitly.

Rather the other way:

[You may use any words you want for the parameter names.](https://sonic-pi.net/tutorial.html#section-5-5)

I came about it while I was trying to develop the following simple  
example:

```ruby
define :mplay do |Melody|
  Melody.each do |note, pause|
    play note
    sleep pause
  end
end

godownmoses = [[:d4, 1],
               [:bb4, 1],
               [:bb4, 1],
               [:a4, 1],
               [:a4, 1],
               [:bb4, 1],
               [:bb4, 1],
               [:g4, 2]]

mplay godownmoses

```

Try it with “melody” and it works.

So

```ruby
define :mplay do |melody|
  melody.each do |Note, Pause|
    play Note
    sleep Pause
  end
end

```

does not work either.

JFI

---

<div class="post-metadata">

**Author:** ![Raul](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/raul/32/265_2.png) [@Raul](https://in-thread.sonic-pi.net/u/Raul)\
**Post date:** [August 26, 2022, 8:00am UTC](https://in-thread.sonic-pi.net/t/formal-argument-cannot-be-a-constant/7035/2 "2022-08-26T08:00:20Z")

</div>

```ruby
define :mplay do |melody|
  melody.each do |note, pause|
    play note
    sleep pause
  end
end

All in lowercase

```
