LanX has asked for the wisdom of the Perl Monks concerning the following question:
I was meditating about designing DSLs and especially how to robustly implement with like in JS to a have clearer and less verbose code.
So I thought to use Tk as a use case and found this 20 year old https://www.perl.com/media/_pub_1999_10_perltk_index/sld001.htm demo.
The code is extremely verbose and I'm asking myself if this is really state of the art.
For instance the code from https://www.perl.com/media/_pub_1999_10_perltk_index/sld010.htm
Is it really necessary to always repeat ...
- -background => 'cyan'
- ->pack()
- and finally my $t1 looks like sloppy code which will generate warnings
my $t1 = $left1->Label(-text => ' ', -background => 'cyan')->pack(); my $t1 = $left1->Label(-text => ' Day ', -background => 'cyan')->pack(); my $t1 = $left1->Label(-text => ' Week ', -background => 'cyan')->pack(); my $t1 = $left1->Label(-text => ' Month ', -background => 'cyan')->pack(); my $t1 = $left1->Label(-text => ' Year ', -background => 'cyan')->pack();
If needed I'd rather implement a helper like:
with ($left1) { default -background => 'cyan'; chain { pack() }; Label(-text => ' '); Label(-text => ' Day '); Label(-text => ' Week '); Label(-text => ' Month '); Label(-text => ' Year '); }
(pseudocode)
But before reinventing the wheel I'd like to discuss my doubts. =)
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Verbose Tk Code
by Corion (Patriarch) on Feb 28, 2021 at 18:28 UTC | |
by LanX (Saint) on Feb 28, 2021 at 18:33 UTC | |
by Discipulus (Canon) on Feb 28, 2021 at 19:31 UTC | |
by LanX (Saint) on Feb 28, 2021 at 20:07 UTC | |
by tybalt89 (Monsignor) on Feb 28, 2021 at 20:47 UTC | |
by LanX (Saint) on Feb 28, 2021 at 20:52 UTC | |
Re: Verbose Tk Code
by kcott (Archbishop) on Mar 01, 2021 at 10:21 UTC | |
Re: Verbose Tk Code
by GrandFather (Saint) on Mar 01, 2021 at 00:30 UTC | |
Re: Verbose Tk Code
by kcott (Archbishop) on Mar 01, 2021 at 12:38 UTC | |
Re: Verbose Tk Code
by jcb (Parson) on Mar 01, 2021 at 04:48 UTC | |
by bliako (Monsignor) on Mar 01, 2021 at 08:41 UTC | |
by jcb (Parson) on Mar 02, 2021 at 02:19 UTC | |
by LanX (Saint) on Mar 02, 2021 at 02:51 UTC | |
by parv (Parson) on Mar 01, 2021 at 06:02 UTC | |
Re: Verbose Tk Code
by Anonymous Monk on Mar 03, 2021 at 00:47 UTC | |
A reply falls below the community's threshold of quality. You may see it by logging in. |