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.
 
  • Post
  • Reply
GameCube
Nov 21, 2006

current scala status: still pretty neato

haven't done anything practical with yet of course, that's when programming stops being fun

Adbot
ADBOT LOVES YOU

Toady
Jan 12, 2009

Cybernetic Vermin posted:

wow, i think that is the first language in the thread i have genuinely never heard of, and it looks entirely uninteresting

are you one of those hipsters who resents c syntax for no reason

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Werthog 95 posted:

anything practical, that's when programming stops being fun

agreed, werthog 95

Toady
Jan 12, 2009

squirrel is essentially lua with built-in classes, sane boolean behavior, errors for undefined variables/table element access, and automatic reference counting

vapid cutlery
Apr 17, 2007

php:
<?
"it's george costanza" ?>

Win8 Hetro Experie posted:

so you're just fine with WoW players making their first lua addon advocating lua and writing addons in lua as how they should be developing software in their day jobs?

hey, while we're at it, let's reward these lua people with meaningless achievements and points too. if WoW sometimes feels like work then work should also feel like WoW, for balance you see

or what if you need a manager to herd your World of Business Forms addon modders? just look for someone with 80 levels worth of leadership experience in a WoW raiding guild, easiest hire ever

no. change lua's syntax until you can't smell the taint of WoW anymore or burn the whole thing to the ground

that's not what i was talking about at all

abraham linksys
Sep 6, 2010

:darksouls:
wrote a lexer for handlebars syntax highlighting in pygments

still baffled that we all use regular expressions in 2013. you'd think people would at least start habitually commenting them, or at least stop leaving them as weird undocumented strings all over the place. i mean no one's made anything better but it's just one of the least intuitive things in coding today

Police Academy III
Nov 4, 2011

abraham linksys posted:

wrote a lexer for handlebars syntax highlighting in pygments

still baffled that we all use regular expressions in 2013. you'd think people would at least start habitually commenting them, or at least stop leaving them as weird undocumented strings all over the place. i mean no one's made anything better but it's just one of the least intuitive things in coding today

emacs has some lispy dsl for writing them but honestly i just end up using weird undocumented strings instead since they take up like 10x less space and who doesn't know how to read a regex in this the thirteenth year of the twenty-first century of our lord and saviour jesus "big jc" christ.

vapid cutlery
Apr 17, 2007

php:
<?
"it's george costanza" ?>

Police Academy III posted:

emacs has some lispy dsl for writing them but honestly i just end up using weird undocumented strings instead since they take up like 10x less space and who doesn't know how to read a regex in this the thirteenth year of the twenty-first century of our lord and saviour jesus "big jc" christ.

you are so amazingly stupid that i'm not surprised at all that you'd write something like this

Police Academy III
Nov 4, 2011

vapid cutlery posted:

you are so amazingly stupid that i'm not surprised at all that you'd write something like this

uh ok gently caress you too buddy

abraham linksys
Sep 6, 2010

:darksouls:
the only good thing about regexes is that there's stuff like http://regexpal.com/ that makes it way less tedious to write

i mean they work they're just one of the few useful things that everyone just gave up making any easier to write

vapid cutlery
Apr 17, 2007

php:
<?
"it's george costanza" ?>

abraham linksys posted:

the only good thing about regexes is that there's stuff like http://regexpal.com/ that makes it way less tedious to write

i mean they work they're just one of the few useful things that everyone just gave up making any easier to write

writing them isn't really that hard because typically you're just trying to generalize from an example. reading them is loving stupid though.

ultramiraculous
Nov 12, 2003

"No..."
Grimey Drawer

vapid cutlery posted:

writing them isn't really that hard because typically you're just trying to generalize from an example. reading them is loving stupid though.

reading them isn't bad. it's finding them in the wild, all alone, without a comment describing their intended input and output.

peak regex

vapid cutlery
Apr 17, 2007

php:
<?
"it's george costanza" ?>

ultramiraculous posted:

reading them isn't bad. it's finding them in the wild, all alone, without a comment describing their intended input and output.

peak regex

ok

Police Academy III
Nov 4, 2011
so have a thing

code:
# terrible regex dsl for python, completely untested
# no attempt is made to eliminate redundant grouping
# terrible abuses of operator overloading ahead
# docs:
# use Rx(s) to create a regex matching s literally
# Rx[...] creates charclasses, use slices for ranges
# e.g. Rx['a':'z', 'A':'Z', '_'] === [a-zA-Z_]
# + is concatenation
# | is |
# use r.group() to create a group around a regex,
# use r.group(name) to create a named one
# unary + is +
# ~ is ?
# r.repeat() is *
# r * i matches i repetitions
# r * (i, j) matches between i and j repetitions
# unary minus creates non-greedy matches after
# using any of the previous 5 operations
# any methods that work on a normal python regex
# should also work on an Rx
# examples:
# Rx['a':'z', 'A':'Z', '_'] + Rx['a':'z', 'A':'Z', '0':'9', '_'].repeat()
#   === "[a-zA-Z_][a-zA-Z0-9_]*
# +(Rx('w') | 'a').group() + -Rx['ab'].repeat()
#   === "(w|a)+[ab]*?"

import re

def _charclass_entry_to_str(s):
    if isinstance(s, str):
        return re.sub("(-|])", r"\\\1", s) if isinstance(s, str) else s
    elif isinstance(s, slice):
        for x in [s.start, s.stop]: assert(isinstance(x, str) and len(x) == 1)
        return s.start + "-" + s.stop
    else:
        assert(False)

class _TerribleHack(type):
    def __getitem__(cls, s):
        if isinstance(s, tuple):
            s = reduce(str.__add__, map(_charclass_entry_to_str, s))
        else:
            s = _charclass_entry_to_str(s)
        return cls("[" + s + "]", False)

class Rx(object):
    _identifier_regex = re.compile(r"[a-zA-Z_][a-zA-Z0-9_]*")
    __metaclass__ = _TerribleHack

    def _maybe_escape(self, s):
        if isinstance(s, Rx):
            return s.s
        elif isinstance(s, str):
            return re.escape(s)
        else:
            assert(False)

    def __init__(self, s="", escape=True):
        if isinstance(s, Rx):
            self.s = s.s
        elif isinstance(s, str):
            self.s = re.escape(s) if escape else s
        else:
            assert(False)
        self.rx = None

    def _wrap(self):
        return "(?:" + str(self) + ")"

    def group(self, name=None):
        if name:
            assert(self._identifier_regex.match(name))
            return self.__class__("(P<" + name + ">" + str(self) + ")", False)
        else:
            return self.__class__("(" + str(self) +")", False)

    def repeat(self):
        return self.__class__(self._wrap() + '*', False)

    def __str__(self):
        return self.s

    def __add__(self, other):
        return self.__class__(str(self) + self._maybe_escape(other), False)
    def __radd__(self, other): self.__class__(other) + self

    def __mul__(self, other):
        if isinstance(other, int):
            return self.__class__(self._wrap() + "{%d}" % i, False)
        elif isinstance(other, tuple):
            assert(len(other) == 2)
            return self.__class__(self._wrap() + "{%d, %d}" % other, False)
        else:
            assert(False)

    def __or__(self, other):
        return self.__class__(self._wrap() + "|" + self.__class__(other)._wrap(), False)
    def __ror__(self, other): return self.__class__(other) | self

    def __neg__(self):
        assert(len(self.s) > 1 and ((self.s[-1] in "}*+" and self.s[-2] != "\\") or (self.s[-1] == "?" and self.s[-2] not in "?\\")))
        return self.__class__(str(self) + "?", False)

    def __invert__(self):
        return self.__class__(self._wrap() + "?", False)

    def __pos__(self):
        return self.__class__(self._wrap() + "+", False)

    def __getattr__(self, name):
        self.rx = self.rx or re.compile(self.s)
        try:
            return getattr(self.rx, name)
        except AttributeError:
            raise AttributeError("'" + self.__class__.__name__ + "' object has no attribute '" + name + "'")

MeruFM
Jul 27, 2010
use sublime text
learn regex

stop wrapping wrappers

Kiwi Ghost Chips
Feb 19, 2011

Start using the best desktop environment now!
Choose KDE!

Police Academy III posted:

so have a thing

code:
# terrible regex dsl for python, completely untested
# no attempt is made to eliminate redundant grouping
# terrible abuses of operator overloading ahead
# docs:
# use Rx(s) to create a regex matching s literally
# Rx[...] creates charclasses, use slices for ranges
# e.g. Rx['a':'z', 'A':'Z', '_'] === [a-zA-Z_]
# + is concatenation
# | is |
# use r.group() to create a group around a regex,
# use r.group(name) to create a named one
# unary + is +
# ~ is ?
# r.repeat() is *
# r * i matches i repetitions
# r * (i, j) matches between i and j repetitions
# unary minus creates non-greedy matches after
# using any of the previous 5 operations
# any methods that work on a normal python regex
# should also work on an Rx
# examples:
# Rx['a':'z', 'A':'Z', '_'] + Rx['a':'z', 'A':'Z', '0':'9', '_'].repeat()
#   === "[a-zA-Z_][a-zA-Z0-9_]*
# +(Rx('w') | 'a').group() + -Rx['ab'].repeat()
#   === "(w|a)+[ab]*?"

import re

def _charclass_entry_to_str(s):
    if isinstance(s, str):
        return re.sub("(-|])", r"\\\1", s) if isinstance(s, str) else s
    elif isinstance(s, slice):
        for x in [s.start, s.stop]: assert(isinstance(x, str) and len(x) == 1)
        return s.start + "-" + s.stop
    else:
        assert(False)

class _TerribleHack(type):
    def __getitem__(cls, s):
        if isinstance(s, tuple):
            s = reduce(str.__add__, map(_charclass_entry_to_str, s))
        else:
            s = _charclass_entry_to_str(s)
        return cls("[" + s + "]", False)

class Rx(object):
    _identifier_regex = re.compile(r"[a-zA-Z_][a-zA-Z0-9_]*")
    __metaclass__ = _TerribleHack

    def _maybe_escape(self, s):
        if isinstance(s, Rx):
            return s.s
        elif isinstance(s, str):
            return re.escape(s)
        else:
            assert(False)

    def __init__(self, s="", escape=True):
        if isinstance(s, Rx):
            self.s = s.s
        elif isinstance(s, str):
            self.s = re.escape(s) if escape else s
        else:
            assert(False)
        self.rx = None

    def _wrap(self):
        return "(?:" + str(self) + ")"

    def group(self, name=None):
        if name:
            assert(self._identifier_regex.match(name))
            return self.__class__("(P<" + name + ">" + str(self) + ")", False)
        else:
            return self.__class__("(" + str(self) +")", False)

    def repeat(self):
        return self.__class__(self._wrap() + '*', False)

    def __str__(self):
        return self.s

    def __add__(self, other):
        return self.__class__(str(self) + self._maybe_escape(other), False)
    def __radd__(self, other): self.__class__(other) + self

    def __mul__(self, other):
        if isinstance(other, int):
            return self.__class__(self._wrap() + "{%d}" % i, False)
        elif isinstance(other, tuple):
            assert(len(other) == 2)
            return self.__class__(self._wrap() + "{%d, %d}" % other, False)
        else:
            assert(False)

    def __or__(self, other):
        return self.__class__(self._wrap() + "|" + self.__class__(other)._wrap(), False)
    def __ror__(self, other): return self.__class__(other) | self

    def __neg__(self):
        assert(len(self.s) > 1 and ((self.s[-1] in "}*+" and self.s[-2] != "\\") or (self.s[-1] == "?" and self.s[-2] not in "?\\")))
        return self.__class__(str(self) + "?", False)

    def __invert__(self):
        return self.__class__(self._wrap() + "?", False)

    def __pos__(self):
        return self.__class__(self._wrap() + "+", False)

    def __getattr__(self, name):
        self.rx = self.rx or re.compile(self.s)
        try:
            return getattr(self.rx, name)
        except AttributeError:
            raise AttributeError("'" + self.__class__.__name__ + "' object has no attribute '" + name + "'")

gross

Cybernetic Vermin
Apr 18, 2005

(aa)*+a matches {a,aaa,aaaaa,...}.
((aa)*+a)* matches {a,aaa,aaaaa,...}. notice that taking the * of a language containing a does not result in a language matching aa.
((aa)*+a)*a matches.... {a}.

perl regular expressions are pretty broken in their compositional semantics. presenting a paper about it at a conference in june in fact.

Cybernetic Vermin fucked around with this message at 09:19 on Apr 10, 2013

Opinion Haver
Apr 9, 2007

wait really

that's weird

Cybernetic Vermin
Apr 18, 2005

to not confuse anyone about the severity, *+ is the 'possessive quantifier', which matches as much as it can and refuses to backtrack. so a*+a matches nothing, the a*+ will always eat all a's so the final a can never match. fact remains that the semantics are largely undocumented, very weird in practice, and the only known implementation technique is a hack in backtracking engines, giving perl and pcre different semantics. working out proper (compositional) semantics made for a neat article

qntm
Jun 17, 2009

ultramiraculous posted:

reading them isn't bad. it's finding them in the wild, all alone, without a comment describing their intended input and output.

peak regex

lol if you use a language which doesn't allow whitespace and comments in regexes

Sapozhnik
Jan 2, 2005

Nap Ghost
vapid cutlery you seem to be mad at a lot of people and i hope you aren't under too much stress in your life ok god bless

Malcolm XML
Aug 8, 2009

I always knew it would end like this.
People should check out whiley a cool language with flow typing allowing you to model assertions in a natural way and have the compiler check them

Intersection types are cool and more languages should have them now that people have figured out that sum/union types are a thing

Also the verification is decidable which is neat.

Malcolm XML
Aug 8, 2009

I always knew it would end like this.
http://whiley.org inshallah

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

so i saw this, said "wow neat" then i saw this : http://whiley.org/2013/01/14/whiley-puzzler-1/ and closed that tab forever

MeruFM
Jul 27, 2010
whitey, the most static plang

abraham linksys
Sep 6, 2010

:darksouls:
operational transformation is cool as hell: http://www.codecommit.com/blog/java/understanding-and-applying-operational-transformation (the bottom part of the article where the graphs get all crazy is still hard for me to grok tho)

graph
Nov 22, 2006

aaag peanuts
im just gonna leave this here:

http://bluehackers.org

ultramiraculous
Nov 12, 2003

"No..."
Grimey Drawer

trex eaterofcadrs posted:

so i saw this, said "wow neat" then i saw this : http://whiley.org/2013/01/14/whiley-puzzler-1/ and closed that tab forever

wait are you saying there's something wrong with this behavior or what.

double sulk
Jul 2, 2010

gas

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

ultramiraculous posted:

wait are you saying there's something wrong with this behavior or what.

not to get all tbc here but permanently retyping a variable due to a query on its type is some academic masturbation of the highest order

MononcQc
May 29, 2007

ultramiraculous posted:

wait are you saying there's something wrong with this behavior or what.

Don't know if I'm woooshing myself here or what, but it sounds like a bad idea that a purely functional g(x) called twice with the same argument can give different results based on the context.

If you can't figure out the type, I'd say you should either disallow the use (say like what Hindley-Milner type systems do) or go dynamic for that call, and maybe warn. Here it just deals with ambiguity by typing with 'any' so that type inference can change how g(x) will be executed based on context rather than the function itself.

Kind of like dynamic scoping, but for type systems. Or maybe there's something I don't get about that one, but that's what it sounds like.

tef
May 30, 2004

-> some l-system crap ->
it seems that the type of the object isn't used in dispatch, but the type of the variable holding the object

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
maybe this is a joke designed to show why most naive static analysis techniques fail

ultramiraculous
Nov 12, 2003

"No..."
Grimey Drawer

trex eaterofcadrs posted:

not to get all tbc here but permanently retyping a variable due to a query on its type is some academic masturbation of the highest order

i guess i'm just used to scala, because it's roughly equivalent to doing a match/case, which is basically a fancy switch that types the output for you

ultramiraculous
Nov 12, 2003

"No..."
Grimey Drawer
the dispatch this is also how scala, and i maybe java too, handles overloaded methods that have covariant parameters. if you have an Object that happens to be a String, you call the method with the Object parameter because the defined behavior is not to do dynamic dispatch. from there you'd figure out its a string and call g(x) with a string type.


it's scala regardless so

trex eaterofcadrs posted:

academic masturbation of the highest order

ultramiraculous fucked around with this message at 19:25 on Apr 10, 2013

raminasi
Jan 25, 2005

a last drink with no ice
i might have misread but it looked like a bad interaction between what was just an implicit unpacking of an object from a union type (which, done explicitly, is bog-standard in languages with union types, right?) and an overloaded g(x)

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

abraham linksys posted:

operational transformation is cool as hell: http://www.codecommit.com/blog/java/understanding-and-applying-operational-transformation (the bottom part of the article where the graphs get all crazy is still hard for me to grok tho)

looks like darcs' patch theory

shrughes
Oct 11, 2008

(call/cc call/cc)
patches can be composed except when they can't be composed yo

Nomnom Cookie
Aug 30, 2009



rebinding variables is a bad idea

silently changing the type of a variable is utterly horrible. its worse than php

a fun esolang would be one that employed the principle of most astonishment tho

Adbot
ADBOT LOVES YOU

coaxmetal
Oct 21, 2010

I flamed me own dad
"use strict";

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply