@faraday and @Thenomain on opposite sides of an issue. It should be a podcast!
Anyhow, I wholeheartedly agree with my compatriot, but I will say that to learn any "real" programming language involves learning some insanely important concepts. Even if you frankencode (definition: taking bits of code from other sources and mashing them together hoping they will work), you have to understand what goes where, a few brief OOP concepts, how stuff gets called, and how to find the help files so you can translate def switch_set(self, target, files, rhs, isadmin):
into English. I mean, sure, you have to do the same with iter()
, but 'help iter' and boom, done.
Does Evennia have a 'help switch_set'? If not, it desperately needs one!
Incidentally, the code comes from https://github.com/evennia/evennia/wiki/Soft-Code, which I have some ethical problems with, mainly how it compares some pretty horribly written softcode in a horribly unformatted manner to elegant and also formatted code. (Yes, I know it's @Volund's code, and I know he is a damn good psychocoder.)
Let us compare the "scare code":
&INC`SET u(ifo)=@include u(ifo)/INC`TARGET;@include \
u(ifo)/INC`FILENAME;@assert strlen(%q<filename>)=@nspemit \
%#=announce(INFO)%BERROR: Info file name empty.;@switch/inline \
gt(strlen(setr(attr,u(u(ifo)/FUN`FINDFILE,%q<target>,%q<filename>))),0)=1,{@assert \
or(isadmin(%
%
files.;@switch/inline or(getstat(%q<target>/%q<attr>`FLAGS,Hidden),\
getstat(%q<target>/%q<attr> `FLAGS,Approved))=1,{@assert \
isadmin(%
be changed by you.}}, ...
To something a little more reasonable:
&INC`SET u(ifo)=
@include u(ifo)/INC`TARGET;
@include u(ifo)/INC`FILENAME;
@assert strlen( %q<filename> )=@nspemit %
@eval setq( attr, u( u( ifo )/FUN`FINDFILE, %q<target>, %q<filename> ));
@if t( strlen( %q<attr> ), 0 )=
1, {
@assert or( isadmin( %
@nspemit %
@switch/inline or(
getstat( %q<target>/%q<attr>`FLAGS, Hidden ),
getstat( %q<target>/%q<attr> `FLAGS, Approved )
)=
1, {
@assert isadmin(%
@nspemit %
}
},
...
There is no reason to softcode unformatted. @Glitch coded an amazing tool called Muxify in order to allow as many people as possible to code formatted. This is so easy to do.
edit:
Incidentally, here's how I would have done it:
&INC`SET u(ifo)=
@include u(ifo)/INC`TARGET;
@include u(ifo)/INC`FILENAME;
@assert strlen( %q<filename> )=@nspemit %
@eval setq( attr, u( u( ifo )/FUN`FINDFILE, %q<target>, %q<filename> ));
@assert cand( strlen( %q<attr> ), cor( isadmin( %
@nspemit %
@assert cor(
not( u( .orflags, %q<target>, %q<attr>, Hidden Approved )),
isadmin( %
)=
@nspemit %
...
Legibility isn't impossible in softcode. In fact, it's not even that hard to do. You just have to start with: I need to be able to tell my future self what the hell I'm doing, and the experience of yelling at your past self for not knowing the things that you know today.