(Untitled)

Apr 30, 2005 19:34

I have a function that takes arguments:

function top (Page p, Entry[] e, Comment[] cs)

And I would like to not have the argument for Entry[] if the function is called from EntryPage, and not to have Comment[] if it's called from Recent/Friends. Is it possible? I tried this, but am getting an error message ("Expected identifier"):

function ( Read more... )

s2 language, question

Leave a comment

Comments 7

hythloday May 1 2005, 03:28:08 UTC
top($this, $this.entries, null);

and

top($this, null, $this.comments);

I would have thought.

Reply

camomiletea May 1 2005, 03:43:04 UTC
Thanks, but that doesn't work either. Same error message. The reason I was thinking I had to add the class is because of what I saw in the Tabular Indent layout. It has a print_entry function with lots of arguments but some only relevant to Friends page, so it does this:

function Page::print_entry (Entry e)
{
print_entry($this, $e, null Color, null Color, false);
}

Reply

hythloday May 1 2005, 12:01:53 UTC
Nulls are typed? Crikey.

Glad you got it sorted in the end.

Reply


fxool May 1 2005, 11:22:51 UTC
Khem..
function RecentPage::lay_spammertop() {
top($this, $this.entries, null Comment[]);
}

function EntryPage::lay_spammertop() {
top($this, null Entry[], $this.comments);
}Looks pretty much the same, right?
Hint: Look at square brackets! :)

Can I, please, get a short description of what You have done with our function? Looks interesting.

Reply

camomiletea May 1 2005, 17:23:17 UTC
Hehe, yes, once I sort everything out. The version that's currently on my journal (when I use my style rather than Flexible Squares, which I'm trying out right now) -- simply makes another function and repeats a bunch of code from your function. I'm just trying to get rid of the redundancy. :)

Regarding your suggestion, I actually tried it at first, but it gave me this error:

"Unknown function top(RecentPage,Entry[],Comment,void[])"

--

I've just tried something that worked. So I will show you what I did. I doubt the comment will fit in all the code. Here's an entry I made - filtered to you (feel free to repost it anywhere): http://www.livejournal.com/users/camomiletea/67600.html

Reply

fxool May 2 2005, 06:51:31 UTC
Thank You! :) Very interesting. Maybe I will repost it in our S2 style community (of course, with reference back to You).

I've had the same problem with null. I don't know why it works on Color, but refuses on any other type.
Mkay, "empty" is a good solution. Didn't know that. Thank You for that too. :)

Reply


Leave a comment

Up