Being a typical Yorkshire lad, I do often struggle with the strict syntax of most modern scripting languages. The solution is 'Ayup' - a programming language for Yorkshire folk. It is powerful enough to quickly parse web pages when you are half way up to your neck in mud; need to run a regular expression when lost on Ilkley moor, and is easy enough to write even when you are steaming from an afternoon in the Dog and Ferret in Harrogate.
Starting a script in Ayup requires the shebang line:
#!/usr/bin/ayup
This provides a path to your Ayup interpretter.
Writing 'Hello World' to the terminal is as simple as:
#!/usr/bin/ayup
wri'aht("Ay up, World!")
It is useful to use a pragma to eliminate unsafe constructs in the dialect. The following code demonstrates this.
#!/usr/bin/ayup
use none o' thy nonsense
wri'aht("Ay up, World!")
cop aye
All scripts in Ayup return 'aye' (true).
Iteration.
Iteration can be performed in a number of ways. Consider the following code fragments.
Displaying all the elements of a list:
#!/usr/bin/ayup
use none o' thy nonsense
fer apiece o'these i' t' (ham):
wri'aht( thi' )
cop aye
Obtaining an iterator from an iterable list:
#!/usr/bin/ayup
use none o' thy nonsense
fer peas in (ham):
wri'aht( peas )
cop aye
Repeating until a condition is met:
#!/usr/bin/ayup
use none o' thy nonsense
repea':
#do something useful
keep buggerin' on until (<condition>)
cop aye
Selection
Boolean statements always evaluate as either 'Aye' or 'Nay' in Yorkshire. Consider:
is (foo > nowt):
aye:
wri'aht("champion")
nay:
wri'aht("eeh by gum")
cop aye
Breaking out of a loop. You can break out of any iteration simply with the pack it in statement.
Consider:use none o' thy nonsense
repea':
#do something useful
keep buggerin' on until (<condition>)
cop aye
Selection
Boolean statements always evaluate as either 'Aye' or 'Nay' in Yorkshire. Consider:
is (foo > nowt):
aye:
wri'aht("champion")
nay:
wri'aht("eeh by gum")
cop aye
Breaking out of a loop. You can break out of any iteration simply with the pack it in statement.
#!/usr/bin/ayup
use none o' thy nonsense
fer apiece o'these i' t' (ham):
wri'aht( thi' )
is (thi' is "peas"):
aye:
pack it in
cop aye
User defined functions
Functions are defined using the keyword mek. Note the use of exception handling in this example.
#!/usr/bin/ayup
use none o' thy nonsense
fram maths impoart random
mek addition( thi' ) wang ValueErrorException:
a = thi' plus t'random.randa(1)
cop a
wri'aht( addition(5) )
aye
That's all for today. Join us next time when we will look at object-oriented Yorkshire, and global (you're not from round here) variables.