Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

array element assignment returns entire array #544

Closed
StefanKarpinski opened this issue Mar 8, 2012 · 6 comments
Closed

array element assignment returns entire array #544

StefanKarpinski opened this issue Mar 8, 2012 · 6 comments
Assignees
Labels
kind:bug Indicates an unexpected problem or unintended behavior

Comments

@StefanKarpinski
Copy link
Sponsor Member

julia> v = [1]
[1]

julia> v[1] = 2
[2]

This regression has been around for a long time. Not even sure when it was introduced, but it's really annoying.

@ghost ghost assigned ViralBShah Mar 8, 2012
@JeffBezanson
Copy link
Sponsor Member

Not a regression. This was always intentional.
In the repl at least you usually want to see the whole array after modifying it.

@ghost ghost assigned JeffBezanson Mar 8, 2012
@StefanKarpinski
Copy link
Sponsor Member Author

This is a regression because we changed this for a long time. It's really, really broken behavior. I do not want to see the array after I assign. Assignment returns the RHS in every single language I can think of.

@JeffBezanson
Copy link
Sponsor Member

Actually, what the assign method returns is independent of what the syntax a[i]=x returns. Should we change all the assign methods, or let assign return whatever it wants and have the front-end arrange for a[i]=x to return x?

@StefanKarpinski
Copy link
Sponsor Member Author

I think having the front end arrange it is better for chained assignments. If it's based on what assign returns then you can have "accidental" conversions through various types instead of each one converting the RHS separately. Admittedly chained assignment is a bit sketchy, but it's also really common and convenient.

@JeffBezanson
Copy link
Sponsor Member

I agree. I'd rather do it that way.

@StefanKarpinski
Copy link
Sponsor Member Author

With immutable composites, chained assignment actually becomes a lot less sketchy — it's a harmless shorthand when the RHS is immutable.

Keno pushed a commit that referenced this issue Oct 9, 2023
* improve builtins consistency check

Use DeepDiffs.jl for printing nice diffs and only print diff if
something actually changed. Also stop hardcoding 1.9 as check for the
build being a nightly version.

* add DeepDiffs in CI

* skip builtin check on Windows
ViralBShah pushed a commit that referenced this issue Jun 25, 2024
Stdlib: SparseArrays
URL: https://github.com/JuliaSparse/SparseArrays.jl.git
Stdlib branch: main
Julia branch: master
Old commit: 82b385f
New commit: e61663a
Julia version: 1.12.0-DEV
SparseArrays version: 1.12.0
Bump invoked by: @ViralBShah
Powered by:
[BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl)

Diff:
JuliaSparse/SparseArrays.jl@82b385f...e61663a

```
$ git log --oneline 82b385f..e61663a
e61663a Update to SuiteSparse 7.7 (#545)
4141e8a Update gen/README.md (#544)
45dfe45 Update ci.yml to ot fail if codecov fails (#541)
0888db6 Bump julia-actions/cache from 1 to 2 (#540)
740b82a test: Don't use GPL module when Base.USE_GPL_LIBS=false (#535)
```

Co-authored-by: Dilum Aluthge <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

3 participants