hi,
i just objserved the following obscure error: if i run Calendar; before doing anything else with the Calendar module, then the module is now missing now();
i guess this has to do with the way the Calendar module is built, and i wonder how this could be prevented other than "don't do this"
greetings, martin.
it appears to work if i move the if(!booted) test from `[]() to create() in Calendar.pmod/module.pmod.
mirar?
greetings, martin.
i was wrong. the actual problem is caused by doing indices(Calendar); and here the move of the boot code into create does not help.
greetings, martin.
it appears to be hilfe related. in a script i can't reproduce it. otoh, in a script the output of indices(Calendar) makes no sense. i only get ({ "Austrian" }) ???
greetings, martin.
it works if i add
array _indices() { return (array)magic; }
to Calendar.pmod/module.pmod
mirar? could that cause any problems?
greetings, martin.
In a script you'd need to do indices(Calendar) first, and then do Calendar.now in a compile afterwards... It can be triggered though.
Well, you need to add the real indices to magic before you return it with _indices, or you can't access ISO or Gregorian instead...
so
array _indices() { return ((array)magic)+::_indices(); }
maybe?
On Mon, May 28, 2007 at 03:40:01PM +0000, Mirar @ Pike developers forum wrote:
Well, you need to add the real indices to magic before you return it with _indices, or you can't access ISO or Gregorian instead...
no. those appear to be added automaticly:
write("%-76#s", sort(indices(Calendar))*"\n");
Austrian Ruleset default_rules Badi Second dwim_day Bahai Stardate dwim_time Calendar SuperTimeRange format_day_iso Coptic Swedish format_day_iso_short Day TZnames format_iso Discordian Time format_iso_short Event TimeRange format_iso_tod Events TimeRanges language Fraction TimeofDay mkrules Gregorian Timezone module Hour Week now II YMD nulltimerange ISO YMD_Time parse ISO_UTC Year ruleset Islamic _sprintf set_language Julian calendar_name set_ruleset Language calendar_object set_timezone Minute datetime timezone Month datetime_name Rule datetime_short_name (11) Result: 1301
that's what i get despite _intices only returning the contents of magic;
return ((array)magic)+::_indices();
maybe?
module.pmod does not inherit anything.
at something like: return (array)magic|indices(defcal||master()->resolv("Calendar")[default_calendar]);
however `[]() contains the line: if ( !magic[what] || (stage && what!="default_rules")) return UNDEFINED; which seems to block access to anything that is not in magic anyways.
btw, this part is totally confusing me: if (!defcal) { if (!iso_utc) `[]("ISO_UTC"); stage++; defcal=master()->resolv("Calendar")[default_calendar]; stage--; }
is master()->resolv("Calendar") not this? i.e. module.pmod? if no, what is it? if yes, how does it resolve default_calendar? that does not seem to exist.
seems wierd...
greetings, martin.
The ISO calendar depends on Timezone which depends on having a calendar, so there's a special case of the ISO calendar called ISO_UTC which doesn't support any other timezone than UTC, so the Timezone class can be created...
If I remember correctly.
There's lots of circular dependencies in there and Pike used to be much worse in supporting that, and there might be residue code from earlier versions of the bootstrapping procedure.
never mind. i found it: default_calendar is defined in localization.h
greetings, martin.
Yes, it's for setting up your local timezone and calendar. At least that was the idea. :)
Anyway, I seem to be able to replicate some sort of problem.
| Pike v7.6 release 112 running Hilfe v3.5 (Incremental Pike Frontend) | > Calendar.now(); | (1) Result: Fraction(Mon 28 May 2007 9:06:18.973085 CEST) | > indices(Calendar); | (2) Result: ({ /* 26 elements */ | "ISO", | ... | "now", | }) | > Calendar.Day(); | Compiler Error: 1:Index 'Day' not present in module 'Calendar'.
| Pike v7.6 release 112 running Hilfe v3.5 (Incremental Pike Frontend) | > Calendar.Day(); | (1) Result: Day(Mon 28 May 2007) | > Calendar.now(); | (2) Result: Fraction(Mon 28 May 2007 9:06:37.998744 CEST) | > indices(Calendar); | (3) Result: ({ /* 27 elements */ | "ISO", | ... | "now", | "Day", | }) | > Calendar.now(); | (4) Result: Fraction(Mon 28 May 2007 9:07:03.519495 CEST) | > Calendar.Hour(); | Compiler Error: 1:Index 'Hour' not present in module 'Calendar'.
It's reproduced without hilfe as well. If indices() is run, it locks up...
adding
array _indices() { return (array)magic; }
seems to make the problem go away...
greetings, martin.
Yes, but it isn't correct. You still miss the symbols from the default calendar (though that is a feature I don't mind losing).
it looks to me as if magic hardcodes the symbols from the ISO calendar. which works as long as ISO is the default calendar.
magic should probably be reduced to what it needs to be. and _indices as well as the check check for magic[what] should be changed to handle magic+indices(defcal)
on further thought, it seems that magic is not needed at all.
shall i just make the changes in cvs for you to look at and revert or improve upon, or do you prefer to come to an agreement through discussion first?
greetings, martin.
As I said, Pike is a lot better resolving circular dependencies today than when that code was written...
As long as nothing is broken I don't mind... I don't develop that module anymore, but I'm happy with filling in the reasoning behind it.
Speaking of the Calendar module, we have some problems with cyclic refs in it. It's very cumbersome having to destruct all the Calendar objects explicitly to avoid that, so it'd be nice to make it strictly acyclic. Could you perhaps give some pointers where to look for that sort of thing?
I think time ranges and possibly enumerating time periods (e.g. getting an array of the Days in a Week) are involved, but I'm not sure (I mostly see the Calendar garbage turning up in memory statistics - I'm very hazy on what the code that generates it really does).
Any hints would be appreciated.
Good question. I wrote it to be non-cyclic and every object *should* be self-contained (except references to language and timezone), but apparently I failed...
So no real ideas, sorry.
Ok. It's still good to know that you had this consideration. Then it ought to be a lot simpler to fix the problem, whatever it is.
Yes, it was one of the issues that got hairy with the first Calendar module I wrote, if I remember correctly, so I really wanted to avoid that in the new version. (Not for cyclicness, mainly, just because of the remaining spaghetti.)
I don't really see why it should be cyclic even now when I look. Checking which variables aren't methods,
foreach (indices(o);;mixed ind)
{ mixed v=o[ind]; if (!functionp(v) || function_object(v)!=o) werror("%O:%O\n",ind,v); } "m":5 "y":2007 "split":0 "md":30 "mnd":31 "wd":3 "wy":2007 "yd":150 "jd":2454251 "yjd":2454102 "nw":-1000 "w":22 "n":1 "rules":Calendar.Ruleset() "is_day":1 "tzn":0 "utco":-1000 "is_ymd":1 "is_timerange":1
I don't get any wiser at all... rules does not have anything pointing back to the calendar, except the timezone, which should only have temporary objects (from Calendar.ISO_UTC).
Maybe implicit parent pointers has something to do with it, or perhaps the quirky assignment of classes and stuff to variables which I haven't managed to understand (also old resolver problem workarounds, I guess).
i need it for tab-completion, and i generally use it to learn about a module, since it is more reliable than the documentation.
at a minimum however, using it should not break the module, which it does here.
greetings, martin.
Well, the Calendar module doesn't do anything when you do indices(Calendar), so I don't feel very guilty and I don't think it's the Calendar part of the code that breaks it.
The master must have some sort of module index cache, that learns from indices.
Does writing an _indices() function in the Calendar module.pmod help?
It was probably a mistake to allow the shortcut Calendar.<timeunit>. Calendar.ISO seems to work perfectly, and indices works as well...
Can you give an example on how you do that? In my Hilfe I can't replicate the problem.
Pike v7.7 release 32 running Hilfe v3.5 (Incremental Pike Frontend)
write("%-76#s", sort(indices(Calendar))*"\n");
Austrian Event Julian Swedish YMD Badi Events Language TZnames default_rules Calendar Gregorian Rule Time mkrules Coptic ISO Ruleset TimeRange module Day ISO_UTC Second TimeRanges Discordian Islamic Stardate Timezone (1) Result: 397
Calendar.now();
Compiler Error: 1:Index now not present in module "Calendar".
Calendar.parse();
Compiler Error: 1:Index parse not present in module "Calendar".
Pike v7.7 release 32 running Hilfe v3.5 (Incremental Pike Frontend)
Calendar.now();
(1) Result: Fraction(Mon 28 May 2007 12:39:48.812834 NZDT)
write("%-76#s", sort(indices(Calendar))*"\n");
Austrian Event Julian Swedish YMD Badi Events Language TZnames default_rules Calendar Gregorian Rule Time mkrules Coptic ISO Ruleset TimeRange module Day ISO_UTC Second TimeRanges now Discordian Islamic Stardate Timezone (2) Result: 411
Calendar.parse();
Compiler Error: 1:Index parse not present in module "Calendar".
greetings, martin.
Can you give an example on how you do that? In my Hilfe I can't replicate the problem.
pike-devel@lists.lysator.liu.se