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

Inconsistent array assignments #69

Open
adudek opened this issue Oct 4, 2018 · 3 comments
Open

Inconsistent array assignments #69

adudek opened this issue Oct 4, 2018 · 3 comments

Comments

@adudek
Copy link

adudek commented Oct 4, 2018

There is a problem when trying to assign array by value to any variable after initialization. I prepared code sample to demonstrate my issue. To my knowledge every case should work exactly the same. What am I missing here?

#!/usr/bin/env bash

source "$( cd "${BASH_SOURCE[0]%/*}" && pwd )/lib/oo-bootstrap.sh"

import util/log
import util/class

class:MyIssue() {
  public string someMessage
  public array someMessageLines

  MyIssue.someStuff() {
    array someMessageLines="$(this someMessage toArray)"
    $var:someMessageLines
    if [[ $($var:someMessageLines length) != 0 ]]; then echo 'This stuff worked '; fi
  }
  MyIssue.someStufff() {
    array someMessageLines
    $var:someMessageLines="$(this someMessage toArray)"
    $var:someMessageLines
    if [[ $($var:someMessageLines length) != 0 ]]; then echo 'This stufff worked '; fi
  }
  MyIssue.someStuffff() {
    this someMessageLines="$(this someMessage toArray)"
    this someMessageLines
    if [[ $(this someMessageLines length) != 0 ]]; then echo 'This stuffff worked '; fi
  }
} 
Type::Initialize MyIssue

MyIssue my
$var:my someMessage = 'automatic
error
handling
with
exceptions
'

$var:my someStuff
echo '----------------'
$var:my someStufff
echo '----------------'
$var:my someStuffff
@niieani
Copy link
Owner

niieani commented Oct 5, 2018

Hmm, reassigning arrays seems unsupported, but you can mutate the variables instead. Unfortunately I don't have the time now to add the support. We might be simplifying the codebase a lot too, see #45.

@adudek
Copy link
Author

adudek commented Oct 6, 2018

If I might suggest any direction of #45, please focus first on data structures. Most used feature of all languages (and frameworks) is array/sets manipulation. Any project success is measured by coparing effort to savings ratio. If robust and easy(ier) data manipulation is not present as key feature, then any framework is but a gimmick. Also making data manipulation priority framework is setting toward stable long-term-support path acquiring bigger and more stable community.

@niieani
Copy link
Owner

niieani commented Oct 6, 2018

@adudek good input! I'll copy this over to #45.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants