Friday, September 30, 2011

USL 3.7.2

I was writing some libraries for my language and realized I was missing out on certain features.  I have added the ability to compare method return values in if-expressions.  Very useful.  I also added the ability to define my own iterators.  Previously iterators have only been the '$' character.  Now iterator symbols may be defined explicitly.  I also fixed the way string literals are parsed.  So you can retrieve variable values inside of quotation marks during certain operations.  It's very useful.  Here are some examples.

Iterators example:
list array

for 1 < 10 (i)
        array += "Element(${i})"
endfor

loop array (item)
        say "Item: ${item}"
endfor

Comparing methods:
object o
        method m(a)
                return $0
        end
end

method m(a)
        return $0
end

if m("foobar") = o.m("foobar")
        say "These methods return the same values."
        say "You can compare return values to variable values as well."
else
        say "This will never be seen."
endif

New string literal parsing system:
method get_host_address(host)
        @host = $0
        @ping ? "ping -n 1 \{@host}"

        @ip = " ";@ip -= @ip
        @start = false

        loop @ping.size (char)
                if @start = true
                        @ip += "${char}"
                endif

                if "${char}" = "["
                        @start = true
                orif "${char}" = "]"
                        @start = false
                endif
        endfor

        @ip -= "]"

        remove @ping
        remove @start
        remove @host

        return @ip
end

@hostname = "chomp.enter host name: "
@address = get_host_address(@hostname)

say "address: \{@address}"

clear_all!

I've updated the MediaWiki and you can find it under the "Hosted Apps" tab at the sourceforge link below.

To download 3.7.2, you can visit any of the following links:

sourceforge
freecode

No comments:

Post a Comment