Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
Wow, you guys know nothing. That facelift is yards better than the design before it. And yes, that gluey top bar is executed oddly.

Adbot
ADBOT LOVES YOU

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
How come in a for loop over a tied array, FETCH gets called twice for each index? Seems kind of... redundant.

I would look for the reason why in the source myself but I don't know how to navigate it.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
You know what, nevermind. It was probably something gay in my implementation of the tied class. v:)v

Triple Tech fucked around with this message at 19:04 on Sep 14, 2009

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
Let's say I have an idea for a framework. Should I publish immediately to CPAN so people can start toying with it or should I hold back until it's "complete"? I know what you're thinking. Triple Tech, you always have ideas! I know. But this time I actually made some proof of concept code, so I know this works somewhat.

The idea is to have LINQ for Perl. If you don't know LINQ, it's a query language for C#. It's like having SQL for lists/arrays or really any collection (trees, graphs, other data providers). Here's what I would think it would look like in Perl:
code:
my $local_collection =
  descend by 'n',
  where { $_->n =~ /Triple/    }
  let     n => 'g_name',
  where { $_->b_id != $_->g_id }
  from    b => $banned_goons,
  from    g => $goons;

my $l = new Lambda;

my $remote_collection =
  descend by 'n',
  where $l->StartsWith(n => 'Triple'),
  let   n => 'g_name',
  where $l->Ne($_->b_id, $_->g_id),
  from  b => $banned_goons,
  from  g => $goons;

my $sexier_collection =
  descend by 'n',
  where $looks_like_me,
  let   n => 'g_name',
  where $is_not_banned,
  from  b => $banned_goons,
  from  g => $goons;

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?

Tim Berners-Lee posted:

I don't know LINQ, but most of it looks to be redundant in perl. Perl already has map, grep, and sort. All you'd be doing is changing the syntax.

That's like saying LINQ is redundant because SQL exists. Which is only partially true.

The point of making a language-integrated query ... language. is so that other people can implement data providers. So of course LINQ for local collections looks like it could be done better with map, grep, and sort. But you can use the remote collections version for both remote and local collections. Then, you could mix and match local and remote collections.

It's like doing a join at runtime between an array and an XML document, without writing a lick of SQL or XPath.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
It's running it from the current working directory. It has nothing to do with your environment variables.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
I might be talking out of my bum. I'm sorry. :(

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
Maybe the flip flop operator can do what you want.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?

Captain Frigate posted:

so does [mah codez] do what I think it does?

No. You usually flip flop between boundaries (like $i == 2 or /START/). If you run your code, you print everything from 3 up.

Why: The code fails until it hits three. At which point it satisfies and flips to the second condition. Code up until that condition is true, it's less than seven. Then, when you hit seven, that second expression is false, so it flops back to the first. But wait, every high number is always greater than 2. So it prints the rest.

You want hard boundaries like Vanadium posted.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
At a really high level, there aren't really types with scalars. (internally, there is, but that's not what we're talking about)

code:
# integer'ed string
my $a = "5";

# string plus integer
$a += 1;

# strung integer
say "I love $a types of beef.";

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?

Filburt Shellbach posted:

To be fair special variables are basically impossible to google for. The further explosion of punctuation is one reason I dislike Perl 6.

This is stupid. If you're within reach of Google, you're within reach of perlvar.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?

CanSpice posted:

I can get perlvar on my iPhone?

You sho can, little boy! Just point yer Safaris to here!

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
Are there any initiatives to get Perl5 or Perl6 onto .NET? It seems like there used to be for Perl5, but I think it's dead now.

I use C# at work and I'm a junkie now, I love it. Perl6 looks good in the way Duke Nukem Forever looks good.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
I've been listening the FLOSS Weekly podcast and I heard about IronPython, Jython, and IronRuby, etc... It made me think, wow, this is almost as bad/crazy as Parrot!

And now I feel like making a chart... Here are all the VMs, .NET, JVM, Parrot, and here are all the languages on top of it... And you can have crazy permutations!

C# on Parrot
IronPerl
JPHP

Although I don't know any sane person that would want to redo the abortion that is PHP. :smug:

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
:psyduck: Just because you can jam everything on to one line doesn't mean you have to.

What's matrix?

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
So... you want to set up a 2D array. Super, that's pretty straight forward. And I'm guessing "matrix" is a key. It should really be quoted to make it more clear. Keys for hashes should be quoted since they are strings/scalars.

If you're doing a 2D array, why would you need a hash? If it's a single value hash/dictionary, that doesn't really make sense. Why not start just at the 2D array?

A 2D array in Perl is not unlike the way it's done in other languages. It's literally an array of arrays. Except that Perl does not support typed or first class 2D arrays (where it isn't an array OF arrays but a native, 2-dimensional data structure with two indices).

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
Well if both values aren't indices starting at zero, it's not really an array, is it? I mean, the storage mechanism could be anything (AoA) but accessing it is a whole different story.

Storing the 10th and 20th values of something results in what, a 20 element array or a 2 element array?

You want a hash of hashes, each key happening to be a number.

code:
$matrix{$x}{$y} = 3.14159
Unless these values are ordered in some significant way and you need easy access to these ordered slices...

Edit: Alternatively, you could have an x_lookup and a y_lookup and a 2D array for storing the values themselves. But that's three data structures instead of one monster one.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
If you value iterating over them cell by cell in order, then a 2D array is the way to go. What I meant by the lookups is that the array indices will have no semantic value to you. Hence the lookup table to provide a mapping between semantic index and array index.

code:
     10  20
.34   1   7
.72   2   5

Stored as

@matrix = [ [ 1, 7 ], [ 2, 5 ] ]

%x = { .34 => 0, .72 => 1 }
%y = {  10 => 0,  20 => 1 }

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
I'm assuming you have you x keys and your y keys already in an ordered list (or some sort of source). If not, then you need to keep sorting them if you iterate over the keys in the lookup hash or keep a regular list of values in their significant order.

There are so many ways of tackling this problem and the answer is IT DEPENDS on your use case. Are you building this structure, are you reading it, does it need to be fast, how are you reading it, etc. All of these things matter and I have no idea what you want.

PS - If building and arbitrary reading are all important, consider making or finding a matrix class that provides ordered and random access, implementation be damned.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?

Mithaldu posted:

:siren: You need to stop golfing your stuff so hard. :siren:

Hey everyone, pro tip! This one, right here!

Just because you can chain nested indices together doesn't mean you should!

code:
# look how awesome my codez are

$megatron->{$artilary}{$squad_leader}[$squad_rank]{$decepticon_$type} = 'Starscream';

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
Golfing. To code emphasizing the least amount of keystrokes. Usually results in lovely, unreadable code.

Captain Frigate posted:

Wow I did that and it worked out great! I assume perl like references better than lots of stacked brackets? I'm not sure what you mean by golfing though.

Ok, so how about assigning hashes to array indices? Would that look something like:

Yes, pretty much. But after the first index, you don't need subsequent arrows for dereferencing.

code:
# untested
# quote your keys goddammit
# can't do key assignment and declaration at the same time

my %hash;
$hash{"label"} = 'My gay label';

my %other_hash = (label => 'My gayer label');

my $hash_ref = \%hash;

my @array = $hash_ref;

print $array[0]{"label"};

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
You know what, I take back what I said about quoting keys. My misunderstanding. :geno:

I thought the default case was it as an expression. Turns out that hasn't been the case for some time. I got it backwards. I'm confusing it with functions that consume parenthesis.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
The canonical example of what I was referring to is:

code:
# "expected" output is 14, from 7 * 2

print (3 + 4) * 2; # prints just 7

# proper statement

print +(3 + 4) * 2; # prints 14

# which I confused with

$a{print}  = 'scalar';      # bareword -> scalar
$a{+print} = 'expression';  # force evaluation
print %a;

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
Wow, way too much crazy going on up there. You have a fundamental misunderstanding with references and how to access them. Granted, I went through the exact same thing, but once you get it, it's pie (except for maybe some weird edge cases or trying to find the last index of an array ref, both of which could easily be addressed by not nesting indices).

Captain Frigate posted:

I have no idea what is happening here. What does the preceding "+" do?

The "unary plus" :airquote: operator forces Perl to evaluate the expression in a different manner. In the first example, it consumes the parenthesis before print can, so print evaluates over the whole expression instead of just the parenthesis. In the second example, you're saying that print should be treated as more than just a bareword, and that you want to plusify (aka do nothing to) the return value of a function called print.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?

Otto Skorzeny posted:

for (('to you', 'dear '.shift)[0,0,1,0]) { print "Happy birthday $_! " }

Mind blown. Is it someone's birthday?

Edit:

code:
> perl -Mfeature=say - namegoeshere
say "Happy birthday $_!" for ('to you', 'dear '.shift)[0,0,1,0]

Triple Tech fucked around with this message at 21:48 on Feb 16, 2010

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
Alter does not return a result set*. If the execute doesn't die, it was successful. Capture in an eval block if you want error detection, as opposed to success detection.

* as far as I know on SQL Server. Typically only SELECT statements do, barring some weird DB implementations

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
The logo is a bikeshed. Larry should kill himself based off that butterfly alone. Both are terrible but obviously Sri's is yards less terrible.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?

satest3 posted:

I like you.

What are the braces referring to?

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
I recently took up a new job in NYC in one of the city's like... five or so active Perl shops. It's like a vicious cycle! Anyway, I should be back on the Perl grind soon. :) I'm going to miss Visual Studio...

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?

Fenderbender posted:

Probably took my last job. ;X

Where did you work and where do you work now?

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
I'm not exactly sure what features Perl6 even has, but it's poised in my head as "The Jesus Language". Whatever killer feature other languages have, Perl6 needs to have. Or, if Perl6 already has it, people just need to be educated about it. The only killer things I can think of are...

* Low barrier parallelization (threads, cores, etc)
* ORM
* Client-side collection querying (like LINQ)
* Web MVC framework (yawn)

Once those spaces have matured (for any language, really), I'm not really sure what's left to do.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
I conflated Perl6 core with its ecosystem. I agree ORM and MVC needn't be core, but client-side querying and parallelization would get a huge boost if they were much closer to the native constructs of the language. Otherwise it'd be another Moose-type project and who needs that. Just make it core.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
You can consume it directly or use more concise notation.

code:
say for @$things;

my @real_things = @$things;

say $things->[1];

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
Keep in mind the above/latest/hash technique won't work if the keys are not unique.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
What is state of developers were you work? (assuming you do Perl full time) We lost three people recently and it's been really hard to find developers of that caliber to replace them. How are you guys coping with the current state of the industry?

Adbot
ADBOT LOVES YOU

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?

EVGA Longoria posted:

Anyone have any tricks for designing complex data structures? I've been doing it in my head but it ends up taking longer than it should to wrap my head around it. I'd like an easy way to (visually, preferably) layout a hash of arrays of hashes and the like to make sure I'm getting all the key pieces.

Maybe you just need to mitigate its complexity? What are you designing?

Arrays for collections, hashes for objects. Dunzo.

  • Locked thread