Skip to content

Data::Dumper Feature Request: TrailingCommas option #15070

Description

@p5pRT

Migrated from rt.perl.org#126813 (status was 'resolved')

Searchable as RT126813$

Activity

  1. p5pRT commented on Dec 5, 2015

    @p5pRT
    Author

    From @kentfredric

    There's a thing we do in Perl frequently for convenience and to reduce the amount of superfluous diff lines in any generated code we write to git, the o'l trailing comma.

    Seeing that unlike JSON, where you need a relaxed implementation of JSON to support it, making it a non-standard feature, Perl itself natively supports the trailing comma, and Data​::Dumper isn't targeting a restricted language schema that prohibits them.

    There's two ways of doing this really​:

    [
      1,
      2,
      3,
    ]

    And

    [
      ,1
      ,2
      ,3
    ]

    Though I only typically see the first.

    I've also seen the following in the wild which leverages that you're more likely to add new items at the end of a list than the start, so reduces diff noise without adding extra "," tokens.

    [
      1
      ,2
      ,3
    ]

    But that looks weird and unbalanced to me.

    Naturally, adding a trailing comma for diff reasons only is of use when its a multi-line array, so people using Indent = 0 wouldn't want it.

    But my next ticket will suggest an option to pack small single-dimensional arrays into single lines even on Indent = 1, and those arrays wouldn't need the trailing comma, but the larger arrays in the same structure that did span multiple lines would need it.


    Flags​:
      category=library
      severity=wishlist
      module=Data​::Dumper


    Site configuration information for perl 5.22.0​:

    Configured by kent at Fri Jun 19 08​:03​:55 NZST 2015.

    Summary of my perl5 (revision 5 version 22 subversion 0) configuration​:
     
      Platform​:
      osname=linux, osvers=4.0.0-gentoo, archname=x86_64-linux
      uname='linux katipo2 4.0.0-gentoo #23 smp preempt sat apr 25 06​:58​:21 nzst 2015 x86_64 intel(r) core(tm) i5-2410m cpu @​ 2.30ghz genuineintel gnulinux '
      config_args='-de -Dprefix=/home/kent/perl5/perlbrew/perls/5.22.0 -Dusecbacktrace -Doptimize= -fno-stack-protector -O3 -march=native -mtune=native -Dman1dir=none -Dman3dir=none -Accflags= -fno-stack-protector -DPERL_HASH_FUNC_SDBM -DUSE_C_BACKTRACE_ON_ERROR -Aldflags= -fno-stack-protector -lbfd -Aeval​:scriptdir=/home/kent/perl5/perlbrew/perls/5.22.0/bin'
      hint=recommended, useposix=true, d_sigaction=define
      useithreads=undef, usemultiplicity=undef
      use64bitint=define, use64bitall=define, uselongdouble=undef
      usemymalloc=n, bincompat5005=undef
      Compiler​:
      cc='cc', ccflags ='-fno-stack-protector -DPERL_HASH_FUNC_SDBM -DUSE_C_BACKTRACE_ON_ERROR -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -DUSE_C_BACKTRACE -g -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
      optimize=' -fno-stack-protector -O3 -march=native -mtune=native',
      cppflags='-fno-stack-protector -DPERL_HASH_FUNC_SDBM -DUSE_C_BACKTRACE_ON_ERROR -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong'
      ccversion='', gccversion='4.9.2', gccosandvers=''
      intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678, doublekind=3
      d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16, longdblkind=3
      ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
      alignbytes=8, prototype=define
      Linker and Libraries​:
      ld='cc', ldflags =' -fno-stack-protector -lbfd -fstack-protector-strong -L/usr/local/lib'
      libpth=/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include-fixed /usr/lib /usr/local/lib /lib/../lib64 /usr/lib/../lib64 /lib /lib64 /usr/lib64 /usr/local/lib64
      libs=-lpthread -lnsl -lnm -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
      perllibs=-lpthread -lnsl -lnm -ldl -lm -lcrypt -lutil -lc
      libc=libc-2.20.so, so=so, useshrplib=false, libperl=libperl.a
      gnulibc_version='2.20'
      Dynamic Linking​:
      dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
      cccdlflags='-fPIC', lddlflags='-shared -fno-stack-protector -O3 -march=native -mtune=native -L/usr/local/lib -fstack-protector-strong'


    @​INC for perl 5.22.0​:
      /home/kent/perl5/perlbrew/perls/5.22.0/lib/site_perl/5.22.0/x86_64-linux
      /home/kent/perl5/perlbrew/perls/5.22.0/lib/site_perl/5.22.0
      /home/kent/perl5/perlbrew/perls/5.22.0/lib/5.22.0/x86_64-linux
      /home/kent/perl5/perlbrew/perls/5.22.0/lib/5.22.0
      .


    Environment for perl 5.22.0​:
      HOME=/home/kent
      LANG (unset)
      LANGUAGE (unset)
      LC_CTYPE=en_NZ.UTF8
      LD_LIBRARY_PATH (unset)
      LOGDIR (unset)
      PATH=/home/kent/perl5/perlbrew/bin​:/home/kent/perl5/perlbrew/perls/5.22.0/bin​:/home/kent/.perl6/2013.04/bin​:/home/kent/.gem/ruby/1.8/bin/​:/home/kent/.rvm/gems/ruby-2.1.2/bin​:/home/kent/.rvm/gems/ruby-2.1.2@​global/bin​:/home/kent/.rvm/rubies/ruby-2.1.2/bin​:/usr/local/bin​:/usr/bin​:/bin​:/opt/bin​:/usr/x86_64-pc-linux-gnu/gcc-bin/5.2.0​:/opt/android-sdk-update-manager/tools​:/opt/android-sdk-update-manager/platform-tools​:/usr/games/bin​:/home/kent/.rvm/bin​:/home/kent/.rvm/bin
      PERLBREW_BASHRC_VERSION=0.72
      PERLBREW_HOME=/home/kent/.perlbrew
      PERLBREW_MANPATH=/home/kent/perl5/perlbrew/perls/5.22.0/man
      PERLBREW_PATH=/home/kent/perl5/perlbrew/bin​:/home/kent/perl5/perlbrew/perls/5.22.0/bin
      PERLBREW_PERL=5.22.0
      PERLBREW_ROOT=/home/kent/perl5/perlbrew
      PERLBREW_VERSION=0.72
      PERL_BADLANG (unset)
      SHELL=/bin/bash

  2. p5pRT commented on Dec 16, 2015

    @p5pRT
    Author

    From @arc

    Thanks for your suggestion. I have implemented this feature in commit cd3393c. This upgrades Data​::Dumper to 2.159 (though that version is not currently available on CPAN).

    I am marking this ticket "pending release"; this version of Data​::Dumper is expected to appear in Perl 5.23.6 (due on or around 2015-12-20), and then in Perl 5.24.0 (due in May 2016).

    --
    Aaron Crane ** http​://aaroncrane.co.uk/

  3. p5pRT commented on Dec 16, 2015

    @p5pRT
    Author

    The RT System itself - Status changed from 'new' to 'open'

  4. p5pRT commented on Dec 16, 2015

    @p5pRT
    Author

    @arc - Status changed from 'open' to 'pending release'

  5. p5pRT commented on May 13, 2016

    @p5pRT
    Author

    From @khwilliamson

    Thank you for submitting this report. You have helped make Perl better.
     
    With the release of Perl 5.24.0 on May 9, 2016, this and 149 other issues have been resolved.

    Perl 5.24.0 may be downloaded via https://metacpan.org/release/RJBS/perl-5.24.0

  6. p5pRT commented on May 13, 2016

    @p5pRT
    Author

    @khwilliamson - Status changed from 'pending release' to 'resolved'

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