quote: Original post by Jotaf
Ok... If lisp is so great, I think you should tell us what''s so good about it (no I''m not being sarcastic) The topic of this thread is "what makes a good scripting language" after all!
Well, ''lisp'' is a little vague.
In general, the primary feature all LISPs have is the ability to treat data as code, and vice versa. This, in turn, leads to the ability to construct domain-specific ''sublanguages'', which can be used interchangeably.
(transform input-stream output-stream (identifier ((/[A-Za-z0-9_]+/))) (expression ((identifier) (get symbol-table identifier)) ((expression "." identifier) (select val from fields where (and (== obj $1) (== name $3)))) ((expression "+" expression)) (+ $1 $3))))
This little example shows part of a parser for a C-style interpreted language. The parser, which is not a builtin LISP feature, directly contains code that performs the interpretation, and an SQL select expression which itself contains LISP code for checking the field values.
quote:
Ok. So you can say that there''s a "longsword" class, and you can create an instance of that class that has all the default behaviour. Then you can add different functions to it so it becomes a "poisoned longsword". This is really simple and straightforward to implement and use. What aspects of OOP would be useful for a structure like this?
An obvious solution is multiple inheritance. However, that has two drawbacks. Firstly, since MI is the evil de jour in OOP theory, I''d get lynched by the code purity mob. Secondly, and notably more importantly, it''s effectively impossible to scale a naïve MI solution to a weapon which inflicts more than N status effects.
class weapon (inventory) { def base_damage = 0; def last_damage; def deal_damage (victim, bonus, multiplier) { last_damage = base_damage * multiplier + bonus; victim.hp -= last_damage; }};modifier poisoned (weapon) { // after the method is called, after deal_damage (victim, ...) { // if the victim fails a fortitude check, if (!victim.fortitudeCheck(18)) { // apply the poisoned status to the victim. victim.status |= Status.POISONED; } }};modifier vampiric (weapon) { after deal_damage(victim, ...) { this.owner.hp += last_damage; }}class longsword (weapon) { def icon = ''icons/weapons/longsword''; // Special syntax for dice rolls. def base_damage = 2d6;};
With this code, you could do poisoned longsword, vampiric longsword, or, without any extra coding, a vampiric poisoned longsword.