slang-users mailing list

[2005 Date Index] [2005 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: [slang-users] Which Way is better?


Hello Ben,

> In latter work, I have started using "push" and "pop" functions, because It
> seemed more convenient and flexible.

Using explicit push/pop to transfer arguments from S-Lang to C scope
obviously yields larger code, and consumes more (but probably negligible)
CPU cycles (due to more function calls, etc).

However, going that route gives you the flexibility of emitting usage()
statements (in C code) when the arguments passed in are incorrect in
either number or type.

My personal opinion is that writing such self-documenting functions is
a win for users.  For example,


	slsh> require("gtk")
	slsh> gtk_window_new
	Usage: GtkWidget = gtk_window_new(int)

	slsh> gtk_container_add
	Usage: gtk_container_add(GtkWidget,GtkWidget)

You could achieve a similar effect by writing an additional layer of
.sl code above the C wrappers,  but it's not always the best approach.

Another advantage of the explicit push/pop approach is that it becomes
possible, e.g., to fabricate default arguments to C++ methods when
calling such from S-Lang.

Hope this helps,
Mike

_______________________________________________
To unsubscribe, visit http://jedsoft.org/slang/mailinglists.html


[2005 date index] [2005 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]