18

5

Mathematica Version 11.2 desktop / Windows 10 Pro 64-bit

I am trying to understand if a symbol can have both OwnValues and DownValues.

Is this acceptable or not acceptable?

As an experiment, I noticed that when one assigns the OwnValues such as "y = a" compared to the DownValues makes a difference which I cannot explain. The following is an example.

```
y[] = b; y[x] = 1; y = a;
??y
```

Global`y

$\qquad$y = a $\quad$ y[ ] = b $\quad$ y[x] = 1

```
{OwnValues[y], DownValues[y]}
(* {{HoldPattern[y]:>a},{HoldPattern[y[]]:>b,HoldPattern[y[x]]:>1}} *)
Remove[y]
y=a; y[]=b; y[x]=1;
??y
```

Global`y

$\qquad$ y = a

```
{OwnValues[y], DownValues[y]}
(* {{HoldPattern[y]:>a}, {}} *)
```

The help says `Set`

( = ) has attribute `HoldFirst`

. Therefore, the lhs should not be evaluated. So it should not matter if you have `y`

, `y[]`

, or `y[x]`

because they are not evaluated. However, for `y = a; y[] = b; y[x] = 1;`

, it does seem to matter since only `y = a`

is defined.

Please clarify.

3

Regarding

– jjc385 – 2017-11-26T23:37:24.507`HoldFirst`

, I immediately thought of Leonid's 2015 comment: "[Having a hold attribute] simply means that arguments are passed to the function in unevaluated form, but does not restrict what functions decide to do with them."1

See the second bullet point in the first chapter in tutorial/Evaluation to learn why this will be a problem.

– Kuba – 2017-11-27T06:23:29.913