Changeset 14650 for src/Pugs/Parser

Show
Ignore:
Timestamp:
11/06/06 02:37:37 (2 years ago)
Author:
audreyt
svk:copy_cache_prev:
41990
Message:

* Pugs.AST.Internals: Allow prototype objects to act as Code

objects, which for now simply delegates named parameters to
the .new call. (In the future it may also serve as coercion.)

my $cerberus = ::Dog(heads => 3);
my $cerberus = ::Dog.new(heads => 3); # same thing

This is semi-specced, but not really formalized, but extremely
handy, so we implement it anyway.

* Pugs.Parser.Operator: Correctly parse for "$x .= (1,2,3)"

to mean "$x = $x.(1,2,3)", so we can write:

my Dog $cerberus .= (heads => 3);

and save three characters of typing.

* Pugs.Parser: Adjust a comment about canonical status as

the ".=meth" term is now canonical in S03.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Parser/Operator.hs

    r14640 r14650  
    431431    return $ \invExp argExp -> case argExp of 
    432432        -- XXX - App meth _ args -> declAssignHack (con ".=" [invExp, App meth Nothing args]) 
    433         App meth _ args -> declAssignHack (con "=" [invExp, App meth (Just invExp) args]) 
     433        App meth _ args 
     434            | meth == Var varTopic  -> declAssignHack (con "=" [invExp, App invExp Nothing args]) 
     435            | otherwise             -> declAssignHack (con "=" [invExp, App meth (Just invExp) args]) 
    434436        _               -> Val (VError (VStr "the right-hand-side of .= must be a function application") []) 
    435437