Skip to content

Bruce's issue with binding and raku -ne #4

Closed

Description

@2colours

This is just a cheap way for me to add a quick note: the binding issue seems to be tied to destructuring in particular; my \k = .split: "|"; will work just fine, my (\k, \l) = .split: "|"; will cause problems.

PS: By the way, could the Github Discussions tab turned on for this repo? It's probably simpler for adding notes like this than fully blown issues.

Activity

  1. jubilatious1 commented on Dec 21, 2024

    @jubilatious1
    Collaborator

    Hi @2colours , the error I'm getting is "cannot assign to a read-only variable or value":

    ~$ cat ~/key_test_4_bruce.txt
    1	KEY2
    2	VAL21
    3	VAL22
    4	VAL23
    5	VAL24

    Now conventional sigil (works fine):

    ~$ raku -ne 'my ($k, $v) = .split: "\t"; say $k => $v;'  ~/key_test_4_bruce.txt
    1 => KEY2
    2 => VAL21
    3 => VAL22
    4 => VAL23
    5 => VAL24

    Now with "sigil-less" variables:

    ~$ raku -ne 'my (\k, \v) = .split: "\t"; say \k => \v;'  ~/key_test_4_bruce.txt
    \("k" => \("KEY2"))
    Cannot assign to a readonly variable or a value
      in block <unit> at -e line 1

    Note: I tried hinting the compiler by adding a numeric parameter to split (telling split how many resultant elements are desired), and saw no improvement.

  2. 2colours commented on Dec 21, 2024

    @2colours
    CollaboratorAuthor

    Hi @jubilatious1 , I can't see here where you are doing anything that involves sigilless variables without destructuring - the my \k = .split("\t"); part. Obviously, that won't do the same thing - but at this point, I don't think that matters too much; it's not relevant for the bug itself.

  3. jubilatious1 commented on Dec 21, 2024

    @jubilatious1
    Collaborator

    Hi @2colours Let me try that:

    % raku -ne 'my (\k, \v) = .split: "\t"; say \k , \v;'  ~/key_test_4_bruce.txt
    \("1")\("KEY2")
    Cannot assign to a readonly variable or a value
      in block <unit> at -e line 1
    
    % raku -ne 'my \k  = .split: "\t"; say \k ;'  ~/key_test_4_bruce.txt
    \(("1", "KEY2").Seq)
    \(("2", "VAL21").Seq)
    \(("3", "VAL22").Seq)
    \(("4", "VAL23").Seq)
    \(("5", "VAL24").Seq)
    % raku -ne 'my \k  = .split("\t").List; say \k ;'  ~/key_test_4_bruce.txt
    \(("1", "KEY2"))
    \(("2", "VAL21"))
    \(("3", "VAL22"))
    \(("4", "VAL23"))
    \(("5", "VAL24"))
    % raku -ne 'my (\k,\v)  = .split("\t").List; say \k,\v ;'  ~/key_test_4_bruce.txt
    \("1")\("KEY2")
    Cannot assign to a readonly variable or a value
      in block <unit> at -e line 1
  4. Repository owner locked and limited conversation to collaborators on Feb 15, 2025
  5. converted this issue into a discussion #10 on Feb 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions