# Changing . to % to access components of derived types

**URL:** <https://fortran-lang.discourse.group/t/changing-to-to-access-components-of-derived-types/8726>\
**Category:** Uncategorized\
**Created:** [October 16, 2024, 1:26pm UTC](https://fortran-lang.discourse.group/t/changing-to-to-access-components-of-derived-types/8726 "2024-10-16T13:26:36Z")\
**Posts on this page:** 4\
**Page:** 2

<div class="post-metadata">

**Author:** ![RonShepard](https://avatars.discourse-cdn.com/v4/letter/r/a3d4f5/32.png) [@RonShepard](https://fortran-lang.discourse.group/u/RonShepard)\
**Post date:** [October 21, 2024, 7:39pm UTC](https://fortran-lang.discourse.group/t/changing-to-to-access-components-of-derived-types/8726/21 "2024-10-21T19:39:54Z")

</div>

> [@ashe](#):
>
> And, of course, not use derived type member names that are the same as operator names.

I challenge anyone to show me a derived type member name with the `.` extension that cannot be used at some later time as an operator name. 😉

---

<div class="post-metadata">

**Author:** ![everythingfunctional](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/everythingfunctional/32/176_2.png) [@everythingfunctional](https://fortran-lang.discourse.group/u/everythingfunctional)\
**Post date:** [October 22, 2024, 1:37pm UTC](https://fortran-lang.discourse.group/t/changing-to-to-access-components-of-derived-types/8726/22 "2024-10-22T13:37:34Z")

</div>

> [@RonShepard](#):
>
> I challenge anyone to show me a derived type member name with the `.` extension that cannot be used at some later time as an operator name.

`a_1`. Don’t ask me why, but a defined operator can only use letters.

> R1024 _defined-binary-op_ **is**. _letter_ [_letter_] … .

---

<div class="post-metadata">

**Author:** ![RonShepard](https://avatars.discourse-cdn.com/v4/letter/r/a3d4f5/32.png) [@RonShepard](https://fortran-lang.discourse.group/u/RonShepard)\
**Post date:** [October 22, 2024, 3:07pm UTC](https://fortran-lang.discourse.group/t/changing-to-to-access-components-of-derived-types/8726/23 "2024-10-22T15:07:00Z")

</div>

> [@everythingfunctional](#):
>
> Don’t ask me why, but a defined operator can only use letters.

I stand corrected. 🙂 I did not remember that restriction. The point I was making, of course, was that it is not possible to know ahead of time which (alphabetic only) component names to avoid in order for the `.` syntax to be universally unambiguous.

---

<div class="post-metadata">

**Author:** ![jwmwalrus](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/jwmwalrus/32/4483_2.png) [@jwmwalrus](https://fortran-lang.discourse.group/u/jwmwalrus)\
**Post date:** [October 22, 2024, 3:13pm UTC](https://fortran-lang.discourse.group/t/changing-to-to-access-components-of-derived-types/8726/24 "2024-10-22T15:13:12Z")

</div>

> [@everythingfunctional](#):
>
> `a_1`. Don’t ask me why, but a defined operator can only use letters.
> 
> > R1024 _defined-binary-op_ **is**. _letter_ [_letter_] … .

This is just speculation, but maybe it’s because the namespaces are not expected to conflict (i.e., you can have both `operator(.nabla.)` and `type(nabla) :: a` in the same scope), and therefore there are no precedence rules. And spaces being insignificant in a fixed-form source tend to complicate things.

If numbers were allowed in user-defined operators, and you had:

```fortran
Call me fixed-form source
      use my_operators, only: operator(.operate1.)
      integer :: operate = 4
      print *, 1 .operate1. 0
      end

```

Then the fixed-form parser could have interpreted the expression in the `print` statement as `1. operate 1.0`… and crashed!

[Previous page](https://fortran-lang.discourse.group/t/changing-to-to-access-components-of-derived-types/8726.md?page=1)
